"SeongUk's Web & System Skill Library"

카운터

Total : 17,418 / Today : 0 / Yesterday : 4
get rss tistory!티스토리가입하기

/**
 * 브라우저의 버전을 체크합니다.
 */


function getbrowser()
{
    var tempdocument = window.document;

    if (tempdocument.all && tempdocument.getelementbyid) // 인터넷 익스플로러 5.x
    {
        return 1;
    }
    else if (tempdocument.all && !tempdocument.getelementbyid) // 인터넷 익스플로러 4.x
    {
        return 2;
    }
    else if (tempdocument.getelementbyid && !tempdocument.all) // 넷스케이프 6
    {
        return 3;
    }
    else if (tempdocument.layers) // 넷스케이프 4.x
    {    
        return 4;
    }
}

/**
 * 팝업창을 원하는 위치에 생성합니다.
 */


function openwindow(url, name, width, height, align, valign, option)
{
    var x,y;
    var window_option = "width="+width+",height="+height;

    if (option!=null) window_option+=","+option;
    if (align==null) align="center";
    if (valign==null) valign="center";

    if (align=="left") x=0;
    else if (align=="right") x=(screen.width-width);
    else if (align=="center") x=(screen.width-width)/2

    if (valign=="top") y=0;
    else if (valign=="bottom") y=(screen.height-height);
    else if (valign=="center") y=(screen.height-height)/2

    window_option+=",left="+x+",top="+y;

    var win = window.open(url,name,window_option);

    focus();
    win.focus();
    return win;
}


/**
 * 윈도우가 열려있는지 체크합니다.
 */


function isalivewindow(win)
{
    if (!win.closed) return true;
    else return false;
}


/**
 * 사운드를 들을수 있는지 환경인지 체크합니다. (ie전용)
 */


function enablesound()
{
  document.write("<object id='player64' classid='clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95' style='display:none'></object>");
  return player64.issoundcardenabled();
}


/**
 * 리얼플레이어(realplayer) 설치 여부 체크합니다.
 */


function enablerealplayer()
{
    var nrealmode=0;
    var nrealplayer5=0;
    var nrealplayer4=0;
    var nrealplayerg2=0;

    if (window.document.all) // ie
    {
        document.write('<script language=vbscript\> \n');
        document.write('on error resume next \n');
        document.write('nrealplayerg2 = (not isnull(createobject("rmocx.realplayer g2 control")))\n');
        document.write('nrealplayer5 = (not isnull(createobject("realplayer.realplayer(tm) activex control (32-bit)")))\n');
        document.write('nrealplayer4 = (not isnull(createobject("realvideo.realvideo(tm) activex control (32-bit)")))\n');
        document.write('</script\> \n');
    }
    else // ns
    {
        var numplugins = navigator.plugins.length;
        for (var i = 0; i < numplugins; i++)
        {
            plugin = navigator.plugins[i];
            if (plugin.name.substring(0,10)=="realplayer")
            {
                nrealmode=1;
            }
        }
    }

    if (nrealmode || nrealplayerg2 || nrealplayer5 || nrealplayer4)
        return true;
    else
        return false;
}


/**
 * 페이지 이동을 합니다.
 * @param        delay        페이지 이동 지연 시간 (milliseconds)
 */


function movepage(str,delay)
{
    if (delay==null)
        window.location.href=str;
    else
        window.setinterval("window.location.href='"+str+"'",delay);
}


/**
 * 현재 히스토리 엔트리에 페이지를 읽어들입니다. (뒤로가기 버튼 비활성화)
 */


function replacepage(str,delay)
{
    if (delay==null)
        window.location.replace(str);
    else
        window.setinterval("window.location.replace('"+str+"')",delay);
}


/**
 * 현재 페이지 새로 고침
 */


function reloadpage(delay)
{
if (delay==null)
        window.location.reload();
    else
        window.setinterval("window.location.reload()",delay);
}


/**
 * 문자열을 클립보드에 복사합니다. (ie전용)
 */


function copytoclip(str)
{
    if (window.document.all) // ie일때
        window.clipboarddata.setdata('text',str);
}


/**
 * 브라우저의 시작페이지 변경창을 띄웁니다. (ie전용)
 */


function sethomepage(url)
{
    window.document.write("<span id='objhomepage' style='behavior:url(#default#homepage); display:none;' >s</span>");
    window.document.all.objhomepage.sethomepage(url);
}


/**
 * 브라우저의 즐겨찾기 추가창을 띄웁니다. (ie전용)
 */


function addfavorite(url, homename)
{
    window.external.addfavorite(url, homename);
}


/**
 * 모니터 해상도를 구합니다.
 */


function getwindowresolution()
{
    if (window.screen)
    {
        var returnarray = new array(2);
        returnarray[0] = window.screen.width;
        returnarray[1] = window.screen.height;
        return returnarray;
    }
    else return false;
}


/**
 * 사용자의 색상 설정을 구합니다.
 * @return        색상비트수를 반환합니다. ( 8비트 : 256색, 16비트 : 하이컬러 , 24비트 : 트루컬러 )
 */


function getwindowcolor()
{
    if (window.screen)
    {
        return screen.colordepth;
    }
}


/**
 * 브라우저의 제목표시줄을 설정합니다.
 */


function setwindowtitle(str)
{
    document.title = str;
}


/**
 * 브라우저의 제목표시줄의 문자열을 반환합니다.
 */


function getwindowtitle()
{
    return document.title;
}


/**
 * 브라우저의 상태표시줄을 설정합니다.
 */


function setstatustitle(str)
{
    window.status = str;
}


/**
 * 브라우저의 상태표시줄의 문자열을 반환합니다.
 */


function getstatustitle()
{
    return window.status;
}


/**
 * 한글 마지막 글자의 중성 유무를 체크합니다.
 *
 * ex ) var str = "사탕";
 *        if (checkfinalconsonant(str)) {
 *           window.alert(str+"을 먹었습니다.");
 *        }
 *        else {
 *           window.alert(str+"를 먹었습니다.");
 *        }
 */


function checkfinalconsonant(str)
{
    var strtemp = str.substr(str.length-1);
    if ((strtemp.charcodeat(0)-16)%28!=0) return true;
    else return false;
}


/**
 * 문자열에 사용해서는 안되는 html태그가 있는지 체크합니다.
 */


function isvalidhtml(str)
{
    var re = new regexp("<[\/]{0,1}[^\f\n\r\t\v]*(html|table|tr|td|script|form|xmp|!|iframe|textarea|input|meta)[^\f\n\r\t\v]*","gi");
    var matcharray = str.match(re);
    if (matcharray) return false;
    else return true;
}


/**
 * 올바른 메일형식인지 체크합니다.
 */


function isvalidemail(str)
{
    var re=new regexp("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$","gi");
    var matcharray=str.match(re);
    if (matcharray) return true;
    else return false;
}


/**

웹(web)/JavaScript 2008/01/30 16:37

즐겨찾기추가

<a href="#" onfocus="this.blur()" onclick="{window.external.AddFavorite('http://www.slimq.com', '다이어트 SlimQ')}">즐겨찾기추가</a>

시작페이지로 설정

<a href="#" style="cursor:hand" onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.slimQ.com');">시작페이지로 설정</a>

웹(web)/JavaScript 2008/01/30 16:35

Gd Library 가 설치되있어야 합니다.


phpinfo() 로 확인 가능하니 확인 해보시고 설치가 되있다면 아래의 함수를 이용하시면 됩니다.


function img_resize( $srcimg, $dstimg, $imgpath, $rewidth, $reheight )
{

 $src_info = getimagesize("$imgpath/$srcimg");

 if($rewidth < $src_info[0] || $reheight < $src_info[1]) {
  if(($src_info[0] - $rewidth) > ($src_info[1] - $reheight)) {
   $reheight = round(($src_info[1]*$rewidth)/$src_info[0]);
  } else {
   $rewidth = round(($src_info[0]*$reheight)/$src_info[1]);
  }
 } else {
  exec("cp $imgpath/$srcimg $imgpath/$dstimg");
  return;
 }

 $dst = imageCreatetrueColor($rewidth, $reheight);

 if($src_info[2] == 1) {
  $src = ImageCreateFromGIF("$imgpath/$srcimg");

  imagecopyResampled($dst, $src,0,0,0,0,$rewidth,$reheight,ImageSX($src),ImageSY($src));
  Imagejpeg($dst, "$imgpath/$dstimg", 80);
 } elseif($src_info[2] == 2) {
  $src = ImageCreateFromJPEG("$imgpath/$srcimg");

  imagecopyResampled($dst, $src,0,0,0,0,$rewidth,$reheight,ImageSX($src),ImageSY($src));
  Imagejpeg($dst, "$imgpath/$dstimg", 80);
 } elseif($src_info[2] == 3) {
  $src = ImageCreateFromPNG("$imgpath/$srcimg");

  imagecopyResampled($dst, $src,0,0,0,0,$rewidth,$reheight,ImageSX($src),ImageSY($src));
  Imagepng($dst, "$imgpath/$dstimg", 80);
 }

 imageDestroy($src);
 imageDestroy($dst);

}



//사용방법

 $thumbL_width  = ''; // 리사이징할 가로 사이즈
 $thumbL_height = ''; // 리사이징할 세로 사이즈

 $upfile_path   = ""; // 화일업로드 경로

 $srcimg = ""; // 리사이징할 화일원본

 $dstimg = ""; // 리사이징 후 화일명

 img_resize($srcimg, $dstimg, $upfile_path, $thumbL_width, $thumbL_height);

웹(web)/PHP 2008/01/18 11:10
1 2 3 4 5  ... 28