This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/handle_flash/main.php

68 lines
1.5 KiB
PHP
Raw Normal View History

<?php
2009-08-20 22:37:17 +00:00
/*
* Name: Handle Flash
* Author: Shish <webmaster@shishnet.org>
* Link: http://code.shishnet.org/shimmie2/
* Description: Handle Flash files. (No thumbnail is generated for flash files)
*/
2009-07-16 19:20:53 +00:00
class FlashFileHandler extends DataHandlerExtension {
/**
* @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));
return true;
}
/**
* @param string $ext
* @return bool
*/
2009-07-16 19:20:53 +00:00
protected function supported_ext($ext) {
$exts = array("swf");
2009-06-05 19:53:00 +00:00
return in_array(strtolower($ext), $exts);
}
/**
* @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) {
$image = new Image();
$image->filesize = $metadata['size'];
2014-04-06 19:47:01 +00:00
$image->hash = $metadata['hash'];
$image->filename = $metadata['filename'];
$image->ext = $metadata['extension'];
2009-01-24 19:05:07 +00:00
$image->tag_array = Tag::explode($metadata['tags']);
$image->source = $metadata['source'];
2014-04-06 19:47:01 +00:00
$info = getimagesize($filename);
if(!$info) return null;
$image->width = $info[0];
$image->height = $info[1];
return $image;
}
/**
2015-09-27 11:38:48 +00:00
* @param string $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;
2014-04-06 19:47:01 +00:00
return true;
}
}