File: thumb.php

package info (click to toggle)
collabtive 2.0%2Bdfsg-5
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 17,708 kB
  • ctags: 27,425
  • sloc: php: 100,872; sh: 72; makefile: 50
file content (54 lines) | stat: -rw-r--r-- 1,385 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
define('CL_ROOT', realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR));

function strip_only_tags($str, $tags, $stripContent=false) {
    $content = '';
    if(!is_array($tags)) {
        $tags = (strpos($str, '>') !== false ? explode('>', str_replace('<', '', $tags)) : array($tags));
        if(end($tags) == '') array_pop($tags);
    }
    foreach($tags as $tag) {
        if ($stripContent)
             $content = '(.+</'.$tag.'(>|\s[^>]*>)|)';
         $str = preg_replace('#</?'.$tag.'(>|\s[^>]*>)'.$content.'#is', '', $str);
    }
    return $str;
}
function getArrayVal(array $array, $name)
{
    if (array_key_exists($name, $array))
    {
        return strip_only_tags($array[$name], "script");
    }
}
error_reporting(0);
$pic = getArrayVal($_GET,"pic");
$height = getArrayVal($_GET,"height");
$width = getArrayVal($_GET,"width");
include(CL_ROOT . "/include/class.hft_image.php");
$imagehw = GetImageSize($pic);
$imagewidth = $imagehw[0];
$imageheight = $imagehw[1];
$myThumb = new hft_image(CL_ROOT . "/" . $pic);
$myThumb->jpeg_quality = 80;

if (!isset($height))
{
	$ratio =  $imageheight / $imagewidth;
	$height = $width * $ratio;

	$height = round($height);
}

if (!isset($width))
{
	$ratio = $imagewidth / $imageheight;
    $width = $height * $ratio;
}

$myThumb->resize($width, $height, 0);

HEADER("Content-Type: image/jpeg");
$myThumb->output_resized("");

?>