Exemplo n.º 1
0
    $arr = unpack("c*", $length_bin);
    $length = 0;
    for ($i = 1; $i <= 4; $i++) {
        $length += pow(256, 4 - $i) * $arr[$i];
    }
    return $length + 12;
}
function next_chunk($binary, $chunk_head_position)
{
    return $chunk_head_position + get_chunk_length($binary, $chunk_head_position);
}
function is_animated($binary, $length)
{
    $chunk_head_position = 8;
    while ($chunk_head_position < $length) {
        if (chunk_type_compare($binary, "IDAT", $chunk_head_position)) {
            return false;
        }
        if (chunk_type_compare($binary, "acTL", $chunk_head_position)) {
            return true;
        }
        $chunk_head_position = next_chunk($binary, $chunk_head_position);
    }
    return false;
}
$filename = $argv[1];
$f = fopen($filename, "rb");
$header = fread($f, 1024);
fclose($f);
var_dump(is_png($header) && is_animated($header, 1024));
Exemplo n.º 2
0
 function insert_post($data)
 {
     if ($data['posttype'] == 'video') {
         // <iframe width="420" height="315" src="//www.youtube.com/embed/jIL0ze6_GIY" frameborder="0" allowfullscreen></iframe>
         // <iframe src="http://player.vimeo.com/video/VIDEO_ID" width="WIDTH" height="HEIGHT" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
     } else {
         if ($data['posttype'] == 'url') {
             /*	$filePath = filePath($data['url']);			
             
             				$this->load->library('upload');
             
             				$this->upload->file_ext = '.'.$filePath['extension'];
             
             				$name = $this->upload->set_filename('./uploads/',$filePath['basename']);
             
             				$img = './uploads/'.$name;
             
             				file_put_contents($img, file_get_contents($data['url']));*/
             $url = $data['url'];
         } else {
             $url = base_url() . 'uploads/' . $data['file'];
         }
         if (is_animated($url)) {
             $data['file_type'] = 'animation';
         } else {
             $data['file_type'] = 'normal';
         }
     }
     $this->db->insert('posts', $data);
     return $this->db->insert_id();
 }
Exemplo n.º 3
0
<?
die;
$where = "";
$params = array();

if (empty($where)) die;

include '../inc.common.php';
include '../engine/upload/functions.php';

$arts = Database::get_vector('art', array('id','md5','extension','resized','animated'), $where, $params);

foreach ($arts as $id => $art) {
	$file = ROOT_DIR.SL.'images'.SL.'booru'.SL.'full'.SL.$art['md5'].'.'.$art['extension'];

	$is_animated = is_animated($file);

	if ($is_animated && empty($art['animated'])) {
		Database::update('art', array('animated' => 1), $id);
	} elseif (!$is_animated && !empty($art['animated'])) {
		Database::update('art', array('animated' => 0), $id);
	}

	if (!empty($art['resized'])) {
		$sizefile = filesize($file);
		$dimensions = getimagesize($file);

		if ($sizefile > 1024*1024) {
			$sizefile = round($sizefile/(1024*1024),1).' мб';
		} elseif ($sizefile > 1024) {
			$sizefile = round($sizefile/1024,1).' кб';
Exemplo n.º 4
0
 function test()
 {
     if (is_animated("./uploads/2014/Jun/post-13204-13360912693.gif")) {
         echo 'animated';
     } else {
         echo 'Not animated';
     }
 }