Merge branch 'develop' of https://github.com/shish/shimmie2 into develop
This commit is contained in:
commit
0fcfa49e75
6 changed files with 49 additions and 24 deletions
|
@ -35,7 +35,6 @@ _d("NICE_URLS", false); // boolean force niceurl mode
|
||||||
_d("WH_SPLITS", 1); // int how many levels of subfolders to put in the warehouse
|
_d("WH_SPLITS", 1); // int how many levels of subfolders to put in the warehouse
|
||||||
_d("VERSION", '2.5.2+'); // string shimmie version
|
_d("VERSION", '2.5.2+'); // string shimmie version
|
||||||
_d("TIMEZONE", null); // string timezone
|
_d("TIMEZONE", null); // string timezone
|
||||||
_d("MIN_FREE_SPACE",100*1024*1024); // int disable uploading if there's less than MIN_FREE_SPACE bytes free space
|
|
||||||
_d("CORE_EXTS", "bbcode,user,mail,upload,image,view,handle_pixel,ext_manager,setup,upgrade,handle_404,comment,tag_list,index,tag_edit,alias_editor"); // extensions to always enable
|
_d("CORE_EXTS", "bbcode,user,mail,upload,image,view,handle_pixel,ext_manager,setup,upgrade,handle_404,comment,tag_list,index,tag_edit,alias_editor"); // extensions to always enable
|
||||||
_d("EXTRA_EXTS", ""); // optional extra extensions
|
_d("EXTRA_EXTS", ""); // optional extra extensions
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ class User {
|
||||||
* would be to use User::by_id, User::by_session, etc.
|
* would be to use User::by_id, User::by_session, etc.
|
||||||
*
|
*
|
||||||
* @param mixed $row
|
* @param mixed $row
|
||||||
|
* @throws SCoreException
|
||||||
*/
|
*/
|
||||||
public function __construct($row) {
|
public function __construct($row) {
|
||||||
global $_user_classes;
|
global $_user_classes;
|
||||||
|
|
|
@ -27,7 +27,7 @@ class FavoriteSetEvent extends Event {
|
||||||
* @param bool $do_set
|
* @param bool $do_set
|
||||||
*/
|
*/
|
||||||
public function __construct(/*int*/ $image_id, User $user, /*boolean*/ $do_set) {
|
public function __construct(/*int*/ $image_id, User $user, /*boolean*/ $do_set) {
|
||||||
assert(is_numeric($image_id));
|
assert(is_int($image_id));
|
||||||
assert(is_bool($do_set));
|
assert(is_bool($do_set));
|
||||||
|
|
||||||
$this->image_id = $image_id;
|
$this->image_id = $image_id;
|
||||||
|
|
|
@ -22,10 +22,17 @@ class VideoFileHandler extends DataHandlerExtension {
|
||||||
global $config;
|
global $config;
|
||||||
$config->set_default_string('video_thumb_engine', 'static');
|
$config->set_default_string('video_thumb_engine', 'static');
|
||||||
$config->set_default_string('thumb_ffmpeg_path', '');
|
$config->set_default_string('thumb_ffmpeg_path', '');
|
||||||
|
|
||||||
|
// By default we generate thumbnails ignoring the aspect ratio of the video file.
|
||||||
|
//
|
||||||
|
// Why? - This allows Shimmie to work with older versions of FFmpeg by default,
|
||||||
|
// rather than completely failing out of the box. If people complain that their
|
||||||
|
// thumbnails are distorted, then they can turn this feature on manually later.
|
||||||
|
$config->set_default_bool('video_thumb_ignore_aspect_ratio', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onSetupBuilding(SetupBuildingEvent $event) {
|
public function onSetupBuilding(SetupBuildingEvent $event) {
|
||||||
global $config;
|
//global $config;
|
||||||
|
|
||||||
$thumbers = array();
|
$thumbers = array();
|
||||||
$thumbers['None'] = "static";
|
$thumbers['None'] = "static";
|
||||||
|
@ -39,19 +46,24 @@ class VideoFileHandler extends DataHandlerExtension {
|
||||||
$sb->add_label("<br>Path to ffmpeg: ");
|
$sb->add_label("<br>Path to ffmpeg: ");
|
||||||
$sb->add_text_option("thumb_ffmpeg_path");
|
$sb->add_text_option("thumb_ffmpeg_path");
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
// Some older versions of ffmpeg have trouble with the automatic aspect ratio scaling.
|
||||||
|
// This adds an option in the Board Config to disable the aspect ratio scaling.
|
||||||
|
$sb->add_label("<br>");
|
||||||
|
$sb->add_bool_option("video_thumb_ignore_aspect_ratio", "Ignore aspect ratio when creating thumbnails: ");
|
||||||
|
|
||||||
$event->panel->add_block($sb);
|
$event->panel->add_block($sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Generate the Thumbnail image for particular file.
|
||||||
|
*
|
||||||
* @param string $hash
|
* @param string $hash
|
||||||
* @return bool
|
* @return bool Returns true on successful thumbnail creation.
|
||||||
*/
|
*/
|
||||||
protected function create_thumb($hash) {
|
protected function create_thumb($hash) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
// this is never used...
|
|
||||||
//$q = $config->get_int("thumb_quality");
|
|
||||||
|
|
||||||
$ok = false;
|
$ok = false;
|
||||||
|
|
||||||
switch($config->get_string("video_thumb_engine"))
|
switch($config->get_string("video_thumb_engine"))
|
||||||
|
@ -62,22 +74,33 @@ class VideoFileHandler extends DataHandlerExtension {
|
||||||
copy("ext/handle_video/thumb.jpg", $outname);
|
copy("ext/handle_video/thumb.jpg", $outname);
|
||||||
$ok = true;
|
$ok = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'ffmpeg':
|
case 'ffmpeg':
|
||||||
$ffmpeg = escapeshellarg($config->get_string("thumb_ffmpeg_path"));
|
$ffmpeg = escapeshellcmd($config->get_string("thumb_ffmpeg_path"));
|
||||||
|
|
||||||
$w = (int)$config->get_int("thumb_width");
|
$w = (int)$config->get_int("thumb_width");
|
||||||
$h = (int)$config->get_int("thumb_height");
|
$h = (int)$config->get_int("thumb_height");
|
||||||
$inname = escapeshellarg(warehouse_path("images", $hash));
|
$inname = escapeshellarg(warehouse_path("images", $hash));
|
||||||
$outname = escapeshellarg(warehouse_path("thumbs", $hash));
|
$outname = escapeshellarg(warehouse_path("thumbs", $hash));
|
||||||
|
|
||||||
$cmd = escapeshellcmd("{$ffmpeg} -i {$inname} -vf scale='if(gt(a,{$w}/{$h}),{$w},-1)':'if(gt(a,{$w}/{$h}),-1,{$h})' -ss 00:00:00.0 -f image2 -vframes 1 {$outname}");
|
if ($config->get_bool("video_thumb_ignore_aspect_ratio") == true)
|
||||||
|
{
|
||||||
|
$cmd = escapeshellcmd("{$ffmpeg} -i {$inname} -ss 00:00:00.0 -f image2 -vframes 1 {$outname}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$scale = 'scale="' . escapeshellarg("if(gt(a,{$w}/{$h}),{$w},-1)") . ':' . escapeshellarg("if(gt(a,{$w}/{$h}),-1,{$h})") . '"';
|
||||||
|
$cmd = "{$ffmpeg} -i {$inname} -vf {$scale} -ss 00:00:00.0 -f image2 -vframes 1 {$outname}";
|
||||||
|
}
|
||||||
|
|
||||||
exec($cmd, $output, $ret);
|
exec($cmd, $output, $returnValue);
|
||||||
|
|
||||||
// TODO: We should really check the result of the exec to see if it really succeeded.
|
if ((int)$returnValue == (int)1)
|
||||||
|
{
|
||||||
$ok = true;
|
$ok = true;
|
||||||
|
}
|
||||||
|
|
||||||
log_debug('handle_video', "Generating thumbnail with command `$cmd`, returns $ret");
|
log_debug('handle_video', "Generating thumbnail with command `$cmd`, returns $returnValue");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +122,6 @@ class VideoFileHandler extends DataHandlerExtension {
|
||||||
* @return Image|null
|
* @return Image|null
|
||||||
*/
|
*/
|
||||||
protected function create_image_from_data($filename, $metadata) {
|
protected function create_image_from_data($filename, $metadata) {
|
||||||
//global $config;
|
|
||||||
|
|
||||||
$image = new Image();
|
$image = new Image();
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ class RegenThumbTheme extends Themelet {
|
||||||
return "
|
return "
|
||||||
".make_form(make_link("regen_thumb"))."
|
".make_form(make_link("regen_thumb"))."
|
||||||
<input type='hidden' name='image_id' value='$image_id'>
|
<input type='hidden' name='image_id' value='$image_id'>
|
||||||
<input type='submit' value='Regenerate'>
|
<input type='submit' value='Regenerate Thumbnail'>
|
||||||
</form>
|
</form>
|
||||||
";
|
";
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,15 +65,18 @@ class Upload extends Extension {
|
||||||
global $config;
|
global $config;
|
||||||
$config->set_default_int('upload_count', 3);
|
$config->set_default_int('upload_count', 3);
|
||||||
$config->set_default_int('upload_size', '1MB');
|
$config->set_default_int('upload_size', '1MB');
|
||||||
|
$config->set_default_int('upload_min_free_space', '100MB');
|
||||||
$config->set_default_bool('upload_tlsource', TRUE);
|
$config->set_default_bool('upload_tlsource', TRUE);
|
||||||
|
|
||||||
|
$this->is_full = false;
|
||||||
|
|
||||||
|
$min_free_space = $config->get_int("upload_min_free_space");
|
||||||
|
if($min_free_space > 0) {
|
||||||
// SHIT: fucking PHP "security" measures -_-;;;
|
// SHIT: fucking PHP "security" measures -_-;;;
|
||||||
$free_num = @disk_free_space(realpath("./images/"));
|
$free_num = @disk_free_space(realpath("./images/"));
|
||||||
if($free_num === FALSE) {
|
if($free_num !== FALSE) {
|
||||||
$this->is_full = false;
|
$this->is_full = $free_num < $min_free_space;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$this->is_full = $free_num < MIN_FREE_SPACE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue