case insensetive file type detection for svg / swf / mp3
git-svn-id: file:///home/shish/svn/shimmie2/trunk@777 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
a649cfffc0
commit
fba18e10fc
@ -11,7 +11,7 @@ class FlashFileHandler extends Extension {
|
|||||||
public function receive_event($event) {
|
public function receive_event($event) {
|
||||||
if(is_null($this->theme)) $this->theme = get_theme_object("handle_flash", "FlashFileHandlerTheme");
|
if(is_null($this->theme)) $this->theme = get_theme_object("handle_flash", "FlashFileHandlerTheme");
|
||||||
|
|
||||||
if(is_a($event, 'DataUploadEvent') && $event->type == "swf" && $this->check_contents($event->tmpname)) {
|
if(is_a($event, 'DataUploadEvent') && $this->supported_ext($event->type) && $this->check_contents($event->tmpname)) {
|
||||||
$hash = $event->hash;
|
$hash = $event->hash;
|
||||||
$ha = substr($hash, 0, 2);
|
$ha = substr($hash, 0, 2);
|
||||||
if(!copy($event->tmpname, "images/$ha/$hash")) {
|
if(!copy($event->tmpname, "images/$ha/$hash")) {
|
||||||
@ -27,18 +27,23 @@ class FlashFileHandler extends Extension {
|
|||||||
send_event(new ImageAdditionEvent($event->user, $image));
|
send_event(new ImageAdditionEvent($event->user, $image));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_a($event, 'ThumbnailGenerationEvent') && $event->type == "swf") {
|
if(is_a($event, 'ThumbnailGenerationEvent') && $this->supported_ext($event->type)) {
|
||||||
$hash = $event->hash;
|
$hash = $event->hash;
|
||||||
$ha = substr($hash, 0, 2);
|
$ha = substr($hash, 0, 2);
|
||||||
// FIXME: scale image, as not all boards use 192x192
|
// FIXME: scale image, as not all boards use 192x192
|
||||||
copy("ext/handle_flash/thumb.jpg", "thumbs/$ha/$hash");
|
copy("ext/handle_flash/thumb.jpg", "thumbs/$ha/$hash");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_a($event, 'DisplayingImageEvent') && $event->image->ext == "swf") {
|
if(is_a($event, 'DisplayingImageEvent') && $this->supported_ext($event->image->ext)) {
|
||||||
$this->theme->display_image($event->page, $event->image);
|
$this->theme->display_image($event->page, $event->image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function supported_ext($ext) {
|
||||||
|
$exts = array("swf");
|
||||||
|
return array_contains($exts, strtolower($ext));
|
||||||
|
}
|
||||||
|
|
||||||
private function create_image_from_data($filename, $metadata) {
|
private function create_image_from_data($filename, $metadata) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ class MP3FileHandler extends Extension {
|
|||||||
public function receive_event($event) {
|
public function receive_event($event) {
|
||||||
if(is_null($this->theme)) $this->theme = get_theme_object("handle_mp3", "MP3FileHandlerTheme");
|
if(is_null($this->theme)) $this->theme = get_theme_object("handle_mp3", "MP3FileHandlerTheme");
|
||||||
|
|
||||||
if(is_a($event, 'DataUploadEvent') && $event->type == "mp3" && $this->check_contents($event->tmpname)) {
|
if(is_a($event, 'DataUploadEvent') && $this->supported_ext($event->type) && $this->check_contents($event->tmpname)) {
|
||||||
$hash = $event->hash;
|
$hash = $event->hash;
|
||||||
$ha = substr($hash, 0, 2);
|
$ha = substr($hash, 0, 2);
|
||||||
if(!copy($event->tmpname, "images/$ha/$hash")) {
|
if(!copy($event->tmpname, "images/$ha/$hash")) {
|
||||||
@ -27,18 +27,23 @@ class MP3FileHandler extends Extension {
|
|||||||
send_event(new ImageAdditionEvent($event->user, $image));
|
send_event(new ImageAdditionEvent($event->user, $image));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_a($event, 'ThumbnailGenerationEvent') && $event->type == "mp3") {
|
if(is_a($event, 'ThumbnailGenerationEvent') && $this->supported_ext($event->type)) {
|
||||||
$hash = $event->hash;
|
$hash = $event->hash;
|
||||||
$ha = substr($hash, 0, 2);
|
$ha = substr($hash, 0, 2);
|
||||||
// FIXME: scale image, as not all boards use 192x192
|
// FIXME: scale image, as not all boards use 192x192
|
||||||
copy("ext/handle_mp3/thumb.jpg", "thumbs/$ha/$hash");
|
copy("ext/handle_mp3/thumb.jpg", "thumbs/$ha/$hash");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_a($event, 'DisplayingImageEvent') && $event->image->ext == "mp3") {
|
if(is_a($event, 'DisplayingImageEvent') && $this->supported_ext($event->image->ext)) {
|
||||||
$this->theme->display_image($event->page, $event->image);
|
$this->theme->display_image($event->page, $event->image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function supported_ext($ext) {
|
||||||
|
$exts = array("mp3");
|
||||||
|
return array_contains($exts, strtolower($ext));
|
||||||
|
}
|
||||||
|
|
||||||
private function create_image_from_data($filename, $metadata) {
|
private function create_image_from_data($filename, $metadata) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ class SVGFileHandler extends Extension {
|
|||||||
public function receive_event($event) {
|
public function receive_event($event) {
|
||||||
if(is_null($this->theme)) $this->theme = get_theme_object("handle_svg", "SVGFileHandlerTheme");
|
if(is_null($this->theme)) $this->theme = get_theme_object("handle_svg", "SVGFileHandlerTheme");
|
||||||
|
|
||||||
if(is_a($event, 'DataUploadEvent') && $event->type == "svg" && $this->check_contents($event->tmpname)) {
|
if(is_a($event, 'DataUploadEvent') && $this->supported_ext($event->type) && $this->check_contents($event->tmpname)) {
|
||||||
$hash = $event->hash;
|
$hash = $event->hash;
|
||||||
$ha = substr($hash, 0, 2);
|
$ha = substr($hash, 0, 2);
|
||||||
if(!copy($event->tmpname, "images/$ha/$hash")) {
|
if(!copy($event->tmpname, "images/$ha/$hash")) {
|
||||||
@ -27,7 +27,7 @@ class SVGFileHandler extends Extension {
|
|||||||
send_event(new ImageAdditionEvent($event->user, $image));
|
send_event(new ImageAdditionEvent($event->user, $image));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_a($event, 'ThumbnailGenerationEvent') && $event->type == "svg") {
|
if(is_a($event, 'ThumbnailGenerationEvent') && $this->supported_ext($event->type)) {
|
||||||
$hash = $event->hash;
|
$hash = $event->hash;
|
||||||
$ha = substr($hash, 0, 2);
|
$ha = substr($hash, 0, 2);
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ class SVGFileHandler extends Extension {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_a($event, 'DisplayingImageEvent') && $event->image->ext == "svg") {
|
if(is_a($event, 'DisplayingImageEvent') && $this->supported_ext($event->image->ext)) {
|
||||||
$this->theme->display_image($event->page, $event->image);
|
$this->theme->display_image($event->page, $event->image);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,6 +64,11 @@ class SVGFileHandler extends Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function supported_ext($ext) {
|
||||||
|
$exts = array("svg");
|
||||||
|
return array_contains($exts, strtolower($ext));
|
||||||
|
}
|
||||||
|
|
||||||
private function create_image_from_data($filename, $metadata) {
|
private function create_image_from_data($filename, $metadata) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user