예제 #1
0
파일: Extended.php 프로젝트: ryochin/h5ai
 public function toHtml()
 {
     $classes = "entry " . ($this->isFolder ? "folder " : "file ") . $this->type;
     $imgClass = "";
     $img = $this->type;
     $smallImg = $this->h5ai->icon($this->type);
     $bigImg = $this->h5ai->icon($this->type, true);
     $hint = "";
     if ($this->isFolder && $this->type !== "folder-parent") {
         $code = $this->h5ai->getHttpCode($this->absHref);
         $classes .= " checkedHttpCode";
         if ($code !== "h5ai") {
             if ($code === 200) {
                 $img = "folder-page";
                 $smallImg = $this->h5ai->icon("folder-page");
                 $bigImg = $this->h5ai->icon("folder-page", true);
             } else {
                 $classes .= " error";
                 $hint = "<span class='hint'> " . $code . " </span>";
             }
         }
     }
     if ($this->h5ai->showThumbs() && in_array($this->type, $this->h5ai->getThumbTypes())) {
         $imgClass = " class='thumb' ";
         $thumbnail = new Thumbnail($this->h5ai, $this->absHref, "square", 16, 16);
         $thumbnail->create();
         $smallImg = file_exists($thumbnail->getPath()) ? $thumbnail->getHref() : $thumbnail->getLiveHref();
         $thumbnail = new Thumbnail($this->h5ai, $this->absHref, "rational", 96, 46);
         $thumbnail->create();
         $bigImg = file_exists($thumbnail->getPath()) ? $thumbnail->getHref() : $thumbnail->getLiveHref();
     }
     $html = "\t<li class='" . $classes . "'>\n";
     $html .= "\t\t<a href='" . $this->absHref . "'>\n";
     $html .= "\t\t\t<span class='icon small'><img " . $imgClass . " src='" . $smallImg . "' alt='" . $img . "' /></span>\n";
     $html .= "\t\t\t<span class='icon big'><img " . $imgClass . " src='" . $bigImg . "' alt='" . $img . "' /></span>\n";
     $html .= "\t\t\t<span class='label'>" . $this->label . $hint . "</span>\n";
     $html .= "\t\t\t<span class='date' data-time='" . $this->date . "000'></span>\n";
     $html .= "\t\t\t<span class='size' data-bytes='" . $this->size . "'>" . $this->size . "</span>\n";
     $html .= "\t\t</a>\n";
     $html .= "\t</li>\n";
     return $html;
 }
예제 #2
0
파일: api.php 프로젝트: niftylettuce/h5ai
    $hrefs = preg_split("/;/", $hrefs);
    $codes = getHttpCodes($h5ai, $hrefs);
    echo count($codes) === 0 ? "{}" : json_encode($codes);
} else {
    if ($action === "thumb") {
        fail(0, "thumbs are disabled", !$options["showThumbs"]);
        list($srcAbsHref, $width, $height, $mode) = checkKeys(array("href", "width", "height", "mode"));
        require_once "inc/Thumbnail.php";
        require_once "inc/Image.php";
        $srcAbsPath = $h5ai->getDocRoot() . rawurldecode($srcAbsHref);
        if (!Thumbnail::isUsable()) {
            Image::showImage($srcAbsPath);
            exit;
        }
        $thumbnail = new Thumbnail($h5ai, $srcAbsHref, $mode, $width, $height);
        $thumbnail->create(1);
        if (file_exists($thumbnail->getPath())) {
            Image::showImage($thumbnail->getPath());
        } else {
            $image = new Image();
            $image->setSource($srcAbsPath);
            $image->thumb($mode, $width, $height);
            $image->showDest();
        }
    } else {
        if ($action === "tree") {
            list($href) = checkKeys(array("href"));
            require_once "inc/Tree.php";
            $absHref = trim($href);
            $absPath = $h5ai->getAbsPath($absHref);
            $tree = new TreeEntry($h5ai, $absPath, $absHref);
예제 #3
0
    Dialog::Alert("파일을 찾을 수 없습니다.");
    exit;
}
$thumb_path = substr($path, 0, strrpos($path, '.')) . '_T_' . $width . '_' . $height;
$thumb_path .= strrchr($path, '.');
// 무단 링크 검사
// 무단링크시에는 hotlink.gif이미지를 뿌려준다.
$check_hotlink = GV::String(File::hotlink);
if (!$check_hotlink || $_SESSION[File::hotlink] != $check_hotlink) {
    $thumb_path = Path::img('hotlink.gif');
}
// 썸네일이 없으면 썸네일 생성
// TODO 무분별한 썸네일을 생성에 대한 대처를 해야함
if (!file_exists($thumb_path)) {
    $thumb = new Thumbnail();
    $thumb->create($width, $height, $path, $thumb_path);
    chmod($thumb_path, 0606);
}
// 이미지 출력
header("content-type: {$file['file_type']}");
header("content-length: " . filesize($thumb_path));
header("pragma: no-cache");
header("expires: 0");
flush();
$fp = fopen($thumb_path, "rb");
while (!feof($fp)) {
    echo fread($fp, 100 * 1024);
    flush();
}
fclose($fp);
flush();
예제 #4
0
                // 너비만큼 높이도 비율로 줄임
                if ($height) {
                    $img['height'] = $height;
                } else {
                    $img['height'] = round($width * $img['height'] / $img['width']);
                }
                $img['width'] = $width;
                /*
                 * 썸네일 생성
                 */
                //$file = $this->Sql('fetch', $img['file_no']);
                $path = Path::Root($img['file_path']);
                // 원본 파일 검사
                if (!file_exists($path)) {
                    Dialog::Alert("파일을 찾을 수 없습니다.");
                    exit;
                }
                $thumb_path = substr($path, 0, strrpos($path, '.')) . '_T_' . $img['width'] . '_' . $img['height'];
                $thumb_path .= strrchr($path, '.');
                // 썸네일이 없으면 썸네일 생성
                if (!file_exists($thumb_path)) {
                    $thumb = new Thumbnail();
                    $thumb->create($img['width'], $img['height'], $path, $thumb_path);
                    chmod($thumb_path, 0606);
                }
                $img['link'] = $thumb_path;
            }
        }
        $result[] = $img;
    }
}
예제 #5
0
    if (isset($_POST['bi']) && $_POST['bi'] !== "") {
        $base_size_image = $_POST['bi'];
    }
    $a = new Thumbnail($resource_image, $base_size_image, $temp_save_image, 85);
    // instantiate the object - 85% compression should do for thumbnails
    $trans_str = '';
    for ($ci = 1; $ci < 7; $ci++) {
        $tvar = '';
        eval("\$tvar = \$_POST['t" . $ci . "'];");
        if ($tvar !== '') {
            $tvar = stripslashes($tvar);
            eval("\$a->" . $tvar . ";");
            $trans_str .= '$var->' . $tvar . ';<br />';
        }
    }
    $a->create();
}
?>
<html>
<head>
<title>extensive GD2+ image manipulation - test/help page</title>
<style>
body
	{
	font-family: Verdana, Arial, Helvetica;
	font-weight: 600;
	}
</style>

</head>
<body bgcolor="#FFFFFF">
예제 #6
0
 /**
  * @abstract Saves single image and text area content to the database
  * @param array $section
  * @param integer $page_id
  * @return array
  * @access public
  */
 private function saveSection_imagetext($section, $page_id)
 {
     $section['show_title'] = isset($section['show_title']) ? $section['show_title'] : false;
     // upload the image and create an image
     $filename = '';
     $thm_name = '';
     $uploads = files()->upload('image_' . $section['next_id']);
     if (is_array($uploads) && isset($uploads[0]) && !empty($uploads[0])) {
         foreach ($uploads as $upload) {
             $filename = $upload['file_name'];
             $thm_name = str_replace($upload['file_extension'], '_thm' . $upload['file_extension'], $upload['file_name']);
             $thm_path = str_replace($upload['file_extension'], '_thm' . $upload['file_extension'], $upload['server_file_path']);
             if (!empty($upload['server_file_path'])) {
                 // resize original if needed
                 if (app()->config('text_image_maxwidth') || app()->config('text_image_maxheight')) {
                     $img_resize = Thumbnail::create($upload['server_file_path']);
                     $img_resize->adaptiveResize(app()->config('text_image_maxwidth'), app()->config('text_image_maxheight'));
                     $img_resize->save($upload['server_file_path']);
                 }
                 // create the smaller thumbnail
                 $thm_create = Thumbnail::create($upload['server_file_path']);
                 if (app()->config('text_image_crop_center')) {
                     $thm_create->adaptiveResize();
                 }
                 $thm_create->adaptiveResize(app()->config('text_image_thm_maxwidth'), app()->config('text_image_thm_maxheight'));
                 $thm_create->save($thm_path);
             }
         }
     } else {
         $filename = $section['image_filename'];
         $thm_name = $section['image_thumbname'];
     }
     // save the data back
     $ins_id = model()->open('section_imagetext_editor')->insert(array('page_id' => $page_id, 'title' => $section['title'], 'content' => $section['content'], 'show_title' => $section['show_title'], 'image_filename' => $filename, 'image_thumbname' => $thm_name, 'image_alt' => $section['image_alt'], 'template' => $section['template']));
     $sections[] = array('placement_group' => $section['placement_group'], 'type' => 'imagetext_editor', 'called_in_template' => $section['called_in_template'], 'id' => $ins_id);
     return $sections;
 }