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 {
|
2014-04-27 19:33:57 +00:00
|
|
|
/**
|
|
|
|
* @param string $hash
|
|
|
|
* @return bool
|
|
|
|
*/
|
2009-07-16 19:20:53 +00: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 19:33:57 +00:00
|
|
|
return true;
|
2007-12-06 03:06:59 +00:00
|
|
|
}
|
|
|
|
|
2014-04-27 19:33:57 +00:00
|
|
|
/**
|
|
|
|
* @param string $ext
|
|
|
|
* @return bool
|
|
|
|
*/
|
2009-07-16 19:20:53 +00:00
|
|
|
protected function supported_ext($ext) {
|
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
|
|
|
}
|
|
|
|
|
2014-04-27 19:33:57 +00:00
|
|
|
/**
|
|
|
|
* @param string $filename
|
|
|
|
* @param array $metadata
|
|
|
|
* @return Image|null
|
|
|
|
*/
|
2012-02-10 04:04:37 +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'];
|
2009-01-24 19:05:07 +00:00
|
|
|
$image->tag_array = 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;
|
|
|
|
}
|
|
|
|
|
2014-04-27 19:33:57 +00:00
|
|
|
/**
|
|
|
|
* @param $file
|
|
|
|
* @return bool
|
|
|
|
*/
|
2012-02-10 04:04:37 +00:00
|
|
|
protected function check_contents(/*string*/ $file) {
|
2014-04-06 19:47:01 +00:00
|
|
|
if (!file_exists($file)) return false;
|
2009-01-04 19:18:37 +00:00
|
|
|
|
2014-04-06 19:47:01 +00: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 19:47:01 +00:00
|
|
|
return true;
|
|
|
|
}
|
2007-12-06 03:06:59 +00:00
|
|
|
}
|
2014-04-26 02:54:51 +00:00
|
|
|
|