2007-12-06 03:06:59 +00:00
|
|
|
<?php
|
2009-08-20 22:37:17 +00:00
|
|
|
/*
|
2010-01-05 10:32:39 +00:00
|
|
|
* Name: Handle Flash
|
2007-12-06 03:06:59 +00:00
|
|
|
* Author: Shish <webmaster@shishnet.org>
|
2012-02-08 02:52:11 +00:00
|
|
|
* Link: http://code.shishnet.org/shimmie2/
|
|
|
|
* Description: Handle Flash files. (No thumbnail is generated for flash files)
|
2007-12-06 03:06:59 +00:00
|
|
|
*/
|
|
|
|
|
2009-07-16 19:20:53 +00:00
|
|
|
class FlashFileHandler extends DataHandlerExtension {
|
2017-09-19 17:55:43 +00:00
|
|
|
protected function create_thumb(string $hash): bool {
|
2010-02-02 01:04:38 +00:00
|
|
|
copy("ext/handle_flash/thumb.jpg", warehouse_path("thumbs", $hash));
|
2014-04-27 19:33:57 +00:00
|
|
|
return true;
|
2007-12-06 03:06:59 +00:00
|
|
|
}
|
|
|
|
|
2017-09-19 17:55:43 +00:00
|
|
|
protected function supported_ext(string $ext): bool {
|
2008-04-08 15:41:11 +00:00
|
|
|
$exts = array("swf");
|
2009-06-05 19:53:00 +00:00
|
|
|
return in_array(strtolower($ext), $exts);
|
2008-04-08 15:41:11 +00:00
|
|
|
}
|
|
|
|
|
2017-09-19 17:55:43 +00:00
|
|
|
protected function create_image_from_data(string $filename, array $metadata) {
|
2007-12-06 03:06:59 +00:00
|
|
|
$image = new Image();
|
|
|
|
|
|
|
|
$image->filesize = $metadata['size'];
|
2014-04-06 19:47:01 +00:00
|
|
|
$image->hash = $metadata['hash'];
|
2007-12-06 03:06:59 +00:00
|
|
|
$image->filename = $metadata['filename'];
|
|
|
|
$image->ext = $metadata['extension'];
|
2017-05-12 07:57:50 +00:00
|
|
|
$image->tag_array = is_array($metadata['tags']) ? $metadata['tags'] : Tag::explode($metadata['tags']);
|
2007-12-06 03:06:59 +00:00
|
|
|
$image->source = $metadata['source'];
|
|
|
|
|
2014-04-06 19:47:01 +00:00
|
|
|
$info = getimagesize($filename);
|
2014-03-30 12:26:48 +00:00
|
|
|
if(!$info) return null;
|
2008-06-14 11:18:41 +00:00
|
|
|
|
|
|
|
$image->width = $info[0];
|
|
|
|
$image->height = $info[1];
|
2008-05-26 21:56:06 +00:00
|
|
|
|
2007-12-06 03:06:59 +00:00
|
|
|
return $image;
|
|
|
|
}
|
|
|
|
|
2017-09-19 17:55:43 +00:00
|
|
|
protected function check_contents(string $tmpname): bool {
|
|
|
|
if (!file_exists($tmpname)) return false;
|
2009-01-04 19:18:37 +00:00
|
|
|
|
2017-09-19 17:55:43 +00:00
|
|
|
$fp = fopen($tmpname, "r");
|
2014-04-06 19:47:01 +00:00
|
|
|
$head = fread($fp, 3);
|
|
|
|
fclose($fp);
|
|
|
|
if (!in_array($head, array("CWS", "FWS"))) return false;
|
2008-05-26 21:56:06 +00:00
|
|
|
|
2014-04-06 19:47:01 +00:00
|
|
|
return true;
|
|
|
|
}
|
2007-12-06 03:06:59 +00:00
|
|
|
}
|
2014-04-26 02:54:51 +00:00
|
|
|
|