2007-12-06 03:06:59 +00:00
|
|
|
<?php
|
2009-08-20 23:37:17 +01: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-07 21:52:11 -05: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 20:20:53 +01:00
|
|
|
class FlashFileHandler extends DataHandlerExtension {
|
2014-04-27 15:33:57 -04:00
|
|
|
/**
|
|
|
|
* @param string $hash
|
|
|
|
* @return bool
|
|
|
|
*/
|
2009-07-16 20:20:53 +01:00
|
|
|
protected function create_thumb($hash) {
|
2010-02-02 01:04:38 +00:00
|
|
|
copy("ext/handle_flash/thumb.jpg", warehouse_path("thumbs", $hash));
|
2014-04-27 15:33:57 -04:00
|
|
|
return true;
|
2007-12-06 03:06:59 +00:00
|
|
|
}
|
|
|
|
|
2014-04-27 15:33:57 -04:00
|
|
|
/**
|
|
|
|
* @param string $ext
|
|
|
|
* @return bool
|
|
|
|
*/
|
2009-07-16 20:20:53 +01:00
|
|
|
protected function supported_ext($ext) {
|
2008-04-08 15:41:11 +00:00
|
|
|
$exts = array("swf");
|
2009-06-05 12:53:00 -07:00
|
|
|
return in_array(strtolower($ext), $exts);
|
2008-04-08 15:41:11 +00:00
|
|
|
}
|
|
|
|
|
2014-04-27 15:33:57 -04:00
|
|
|
/**
|
|
|
|
* @param string $filename
|
|
|
|
* @param array $metadata
|
|
|
|
* @return Image|null
|
|
|
|
*/
|
2012-02-09 23:04:37 -05: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 20:47:01 +01:00
|
|
|
$image->hash = $metadata['hash'];
|
2007-12-06 03:06:59 +00:00
|
|
|
$image->filename = $metadata['filename'];
|
|
|
|
$image->ext = $metadata['extension'];
|
2009-01-24 11:05:07 -08:00
|
|
|
$image->tag_array = Tag::explode($metadata['tags']);
|
2007-12-06 03:06:59 +00:00
|
|
|
$image->source = $metadata['source'];
|
|
|
|
|
2014-04-06 20:47:01 +01:00
|
|
|
$info = getimagesize($filename);
|
2014-03-30 13:26:48 +01: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;
|
|
|
|
}
|
|
|
|
|
2014-04-27 15:33:57 -04:00
|
|
|
/**
|
2015-09-27 12:38:48 +01:00
|
|
|
* @param string $file
|
2014-04-27 15:33:57 -04:00
|
|
|
* @return bool
|
|
|
|
*/
|
2012-02-09 23:04:37 -05:00
|
|
|
protected function check_contents(/*string*/ $file) {
|
2014-04-06 20:47:01 +01:00
|
|
|
if (!file_exists($file)) return false;
|
2009-01-04 11:18:37 -08:00
|
|
|
|
2014-04-06 20:47:01 +01:00
|
|
|
$fp = fopen($file, "r");
|
|
|
|
$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 20:47:01 +01:00
|
|
|
return true;
|
|
|
|
}
|
2007-12-06 03:06:59 +00:00
|
|
|
}
|
2014-04-25 22:54:51 -04:00
|
|
|
|