하늘 바람님의 이미지갤러리 (썸네일부분만) > PHP

본문 바로가기
사이트 내 전체검색

PHP

하늘 바람님의 이미지갤러리 (썸네일부분만)

페이지 정보

profile_image
작성자 최고관리자
댓글 0건 조회 16,508회 작성일 21-02-09 11:33

본문

<?
 session_start();       
 include "./auth.inc";
 ?>

 <HTML>
 <HEAD>

        <META HTTP-EQUIV='Content-Type' content='text/html; charset=ks_c_5601-1987'>
        <META HTTP-EQUIV='Pragma' CONTENT='no-cache'>
        <META HTTP-EQUIV='Cache-Control' CONTENT='no-cache'>

        <LINK REL=STYLESHEET TYPE=text/css HREF=../white.css>
        <LINK REL='SHORTCUT ICON' href=http://www.phpresource.org/favicon.ico>       
 </head>
 <BODY>
 <BR><BR>
 <?
 if($mode == "") {
        echo("
                        <form method=post action='$PHP_SELF'>
                        <input type=hidden name=mode value='add'>
                        <input type=hidden name=category_id value='$category_id'>
                        <table border=0 cellspacing=0 cellpadding=0 width=600>
                        <TR>
                        <TD colspan=2 bgcolor=#c8d8f8 align=center>
                                <B>$category_top
                ");
                if($category_sub1 != "") echo(" 》$category_sub1 ");
                if($category_sub2 != "") echo(" 》$category_sub2");
                echo("</B>
                        <TR>
                        <TD align=center> <BR>
                          ADD Dir : 
                            ServerHOME/data/<input type=text class=text size=30 maxlength=70 name=dir>
                                  <input type=image src='../icon/submit.gif' border=0 align=absmiddle onfocus=\"this.blur()\">
                                  <BR><BR>
                        <TR>
                        <TD align=center colspan=2 bgcolor=#c8d8f8>
                        ∴ Special Character는 사용하실 수 없습니다. (',\",....) <BR>
                       
                        </table>
                        </form>

                ");
 }
 if($mode == "add") {
        if($category_id == "") message("Category ID가 입력되지 않았습니다.");
        if($dir == "") message("Directory가 입력되지 않았습니다.");
 //        exec("../per");
       
       
        echo("
                <table border=0>
                <TR>
                <TD bgcolor=#c8d8f8 align=center>
                <B>$dir Directory의 Image 파일 등록</B>
                </table>
               
                ");
               
        $dir_open = "../data/" . $dir;
        $thumb_dir = $dir_open . "/thumb";
        mkdir($thumb_dir,0777);
       

        if(is_writeable($dir_open) != "1") message("$dir_open 에 쓰기 권한이 없습니다.");
       
        $handle = opendir($dir_open);
       
        while(false!==($file=readdir($handle))) {
                if($file!= "." && $file!="..") {
                        //////////////////////////////////////////////
                        $filename = $file;
                        $file_dir_o = $dir_open . "/" . $filename;
                        $file_dir_t = "../tmp/" . $filename . ".pnm";
                        $file_dir_thumb = $thumb_dir . "/" . $filename . ".jpg";
                       
                        $img_size = getimagesize($file_dir_o);                                  // 이미지 사이즈 구하기 (배열 리턴)
                        $img_width = $img_size[0];                                                                // 이미지 가로 사이즈
                        $img_height = $img_size[1];                                                                // 이미지 세로 사이즈

                        $file_size = ceil(filesize($file_dir_o)/1024);                        // 이미지 파일 크기 구하기 (KB)로 환산

                       
                        // 손톱그림 만들기 전 이미지 사이즈 구하기
                        if($img_width < 100 && $img_height < 100) {  // 100*100 이하인 경우 그대로...
                                $go_width = $img_width;
                                $go_height = $img_height;
                        }
                        else        {
                                if($img_width > $img_height) {        // 가로가 세로보다 클 경우 가로를 기준으로 줄여서 세로를 가로를 줄일 비율 만큼 줄인다.                                               
                                        if($img_width > 100) {
                                                $go_width = 100;
                                                $go_per = $img_width / 100;
                                                if($img_height > 50) $go_height = ceil($img_height / $go_per);
                                                else $go_height = $img_height;
                                        }       
                                }
                                else {  // 세로가 가로보다 클 경우 .................
                                        if($img_height > 100) {
                                                $go_height = 100;
                                                $go_per = $img_height / 100;
                                                if($img_width > 50) $go_width = ceil($img_width / $go_per);
                                                else $go_width = $img_width;
                                        }       
                                }
                        }
                       
                        $file_name = explode(".",$file);
                        $file_ext = strtolower($file_name[1]); // 소문자로 변환해서 화일 확장자 추출
                       
                        if($file_ext == "gif") {
                                $sh = "giftopnm ". $file_dir_o . " > " . $file_dir_t;
                                exec($sh);
                                $sh2 = "pnmscale -xy " . $go_width . " " . $go_height . " " . $file_dir_t . " | cjpeg -progressive -optimize -smooth 20 -outfile " . $file_dir_thumb;
                                exec($sh2);
                                unlink($file_dir_t); // 임시 파일 삭제
                        }
                        if($file_ext == "jpg" || $file_ext == "jpeg") {
                                $sh = "djpeg -pnm " . $file_dir_o . " > " .$file_dir_t ;
                                exec($sh);
                                $sh2 = "pnmscale -xy " . $go_width . " " . $go_height . " " . $file_dir_t . " | cjpeg -progressive -optimize -smooth 20 -outfile " . $file_dir_thumb;
                                exec($sh2);
                                unlink($file_dir_t); // 임시파일 삭제
                        }
                        if($file_ext == "jpg" || $file_ext == "jpeg" || $file_ext == "gif") {
                        $wdate = time();
                        $input_qry = "insert into image values('','$wdate','$category_id','$file_dir_o','$img_width','$img_height','$file_size')";
                        mysql_query($input_qry) or message("$file_dir_o 처리 도중 DB 에러 발생");
                        echo("<B>$filename</B> ($img_width($go_width) * $img_height($go_height) : $file_size KB): 정상적으로 등록되었습니다.<BR> ");
                        }

                       
                        //////////////////////////////////////////////                       
                        }
        }
        closedir($handle);
       
       
 }
 ?>

 <P><BR>
 <a href='../' onfocus="this.blur()"><img src='../icon/allow.gif' border=0 align=absmiddle></a> <a href='../' onfocus="this.blur()">HomePage</A>
 </BODY>
 </HTML>

댓글목록

등록된 댓글이 없습니다.

회원로그인

회원가입

  • 게시물이 없습니다.

접속자집계

오늘
1,184
어제
4,401
최대
6,642
전체
887,147
contact : webmaster@beautipia.co.kr
Copyright © beautipia.co.kr. All rights reserved.