2009년 10월 22일 목요일

[자바스크립트] 팝업창 로드시 세로 길이 자동 조정



<script language="JavaScript">
<!--
 function reSizePopup(){
  window.resizeTo(512, document.body.scrollHeight+30);
 }
//-->
</script>


<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0" bgcolor="#EBE3D7" onload="reSizePopup()">

2009년 10월 9일 금요일

[PHP] PHP SetCookie 사용법 (쿠키 Cookie)



Examples

Some examples follow how to send cookies:

Example #1 setcookie()>$2 send example

<?php
$value
= 'something from somewhere'
;

setcookie("TestCookie", $value
);
setcookie("TestCookie", $value, time()+3600);  
/* expire in 1 hour */
setcookie("TestCookie", $value, time()+3600, "/~rasmus/", ".example.com", 1
);
?>

Note that the value portion of the cookie will automatically be urlencoded when you send the cookie, and when it is received, it is automatically decoded and assigned to a variable by the same name as the cookie name. If you don't want this, you can use setrawcookie() instead if you are using PHP 5. To see the contents of our test cookie in a script, simply use one of the following examples:

<?php
// Print an individual cookie
echo $_COOKIE["TestCookie"
];
echo
$HTTP_COOKIE_VARS["TestCookie"
];

// Another way to debug/test is to view all cookies
print_r($_COOKIE
);
?>

Example #2 setcookie()>$2 delete example

When deleting a cookie you should assure that the expiration date is in the past, to trigger the removal mechanism in your browser. Examples follow how to delete cookies sent in previous example:

<?php
// set the expiration date to one hour ago
setcookie ("TestCookie", "", time() - 3600
);
setcookie ("TestCookie", "", time() - 3600, "/~rasmus/", ".example.com", 1
);
?>

Example #3 setcookie()>$2 and arrays

You may also set array cookies by using array notation in the cookie name. This has the effect of setting as many cookies as you have array elements, but when the cookie is received by your script, the values are all placed in an array with the cookie's name:

<?php
// set the cookies
setcookie("cookie[three]", "cookiethree"
);
setcookie("cookie[two]", "cookietwo"
);
setcookie("cookie[one]", "cookieone"
);

// after the page reloads, print them out
if (isset($_COOKIE['cookie'
])) {
    foreach (
$_COOKIE['cookie'] as $name => $value
) {
        echo
"$name : $value <br />\n"
;
    }
}
?>

The above example will output:

three : cookiethree
two : cookietwo
one : cookieone

2009년 10월 6일 화요일

[자바스크립트] 레이어 드래그 & 드롭



# 20080127 수정
 : 드래그 엘리먼트를 따로 지정할 수 있음
 : Direction 코드값 변경


사용법 : new Drag(AttributeName , DragElement , DragAreaNode , DragDirection , ScalePercentageAttributeName);
 - AttributeName : Element 클릭시 Element.getAttribute(AttributeName) 의 값이 "true" 일 때 Element를 드래그
 - DragElement : 해당 Element에 설정시 eval(Element.getAttribute(DragElement)) 를  드래그엘리먼트로 인식
 - DragAreaNode : 해당 Element에 설정시 eval(Element.getAttribute(DragAreaNode)) 하위노드에서만 드래그 가능
 - DragDirection(드래그가능방향) : Element.getAttribute(DragDirection)=[0 - Both , 1 - Horizontal , 2 - Vertical], 설정안할경우 Both
 - ScalePercentageAttributeName : Element.getAttribute(ScalePercentageAttributeName) 가 설정된 드래그 객체에 한해 DragAreaNode 로부터 Element 의 드래그범위를 설정한 비율로 리턴받을수있음(Object.ScaleX , Object.ScaleY)

 * 사용자 편의를 고려해서 최대한 각 Element의 이벤트핸들러나 기본속성에 접근하지 않는 방법을 선택했습니다. 그러다보니 거의 대부분을 사용자 확장 태그값으로 컨트롤 했는데 혹시 이 방법이 어떤 다른 이유에서 안좋다거나 하신분들은 의견 바랍니다.




<span id="text1" style="font-size:12pt;">Drag&Drop</span>

<br>

<embed id="music1" src="http://cfs9.blog.daum.net/upload_control/download.blog?fhandle=MEhUd09AZnM5LmJsb2cuZGF1bS5uZXQ6L0lNQUdFLzAvMTAud21h&filename=10.wma&filename=%ED%8B%B0%28%EC%9C%A4%EB%AF%B8%EB%9E%98%29-%EC%8B%9C%EA%B0%84%EC%9D%B4%ED%9D%90%EB%A5%B8%EB%92%A4.wma" autostart="true"></embed>

<br>

<div style="width:300px; height:300px; background:#72C31B;" draggable="true">Drag : free</div>
<div style="width:200px; height:200px; background:#FFA500; position:absolute;" id="div1" draggable="true" dragarea="document.body">dragarea : body
<input type="text" id="GridPositionX">
</div>
<div style="width:100px; height:100px; background:#FF0000;" draggable="true" dragarea="document.getElementById('div1')">dragarea : div1</div>

<img id="gridX" src="http://sstatic.naver.com/search/mypocket/v3/btn_atcmp_on_op2.gif" draggable="true" dragarea="document.getElementById('div1')" dragdirection="1" scalepercent="10000" onmousedown="return false" onmousemove="return false" title="HORIZONTAL">
<img id="gridY" src="http://sstatic.naver.com/search/mypocket/v3/btn_atcmp_on_op2.gif" draggable="true" dragarea="document.getElementById('div1')" dragdirection="2" scalepercent="500" onmousedown="return false" onmousemove="return false" title="VERTICAL">

<div id="dd" style="background:#000000; width:100px; height:100px;"><br>
<div style="background:#FFFFFF; cursor:move;" draggable="true" dragelement="document.getElementById('dd')">dragelement : parent</div>
</div>

<script language="javascript" src="Drag.js"></script>
<script language="javascript">
//기본설정
var myDrag = new Drag("draggable","dragelement","dragarea","dragdirection","scalepercent");
//기본설정

//응용설정
myDrag.addEvent(document,"onmousemove",function () {
    document.getElementById("GridPositionX").value = myDrag.ScaleX + " : " + Math.ceil(myDrag.ScaleX / 100) + "%";
    document.getElementById("music1").volume = myDrag.ScaleX - Number(document.getElementById("gridX").getAttribute("scalepercent"));
    document.getElementById("text1").style.fontSize = ((myDrag.ScaleY <= 12) ? 12 : myDrag.ScaleY) + "px";
});
//응용설정
</script>

2009년 9월 17일 목요일

[리눅스] FTP 폴더 목록 권한 설정



FTP 폴더가 /home 디렉 토리 아래 일반 계정 디렉토리와 함께 존재 할경우

/home 까지만 접근 하도록 하는 디렉토리 권한 설정 방법이다.


1. 일단 특정 그룹을 생성한다. (필자의 경우 ftp 그룹생성)

$addgroup ftp




2. /home 과 /home/FTP 폴더의 그룹 권한을 변경한다.

$chown root.ftp -R /home/



3. 사용자를 생성하거나 기존 사용자를 FTP 그룹에 추가 한다.
$vi /etc/group 해서
ftp 계정 부분에 ftp 를 사용하게 할 사용자를 추가한다.



4. vsftpd 설정을 바꾼다
$vi /etc/vsftpd.config
chroot_local_user=YES 부분을 찾아 주석을 제거한다 이렇게 하면 사용자는 자기 폴더 상위를 접근 못하게 된다.




5. 4번까지만 하면 자기 폴더 상위는 접근 못하게 되므로 상위에 있는 FTP 폴더를 접근 못한다.
따라서 아래와 같이 변경해준다.

$usermod -d /home/ 사용자
이렇게 해주면 해당 사용자는 /home/폴더 아래에 있는 모든 폴더 들이 보여진다 물론 FTP 폴더도 접근 가능해진다. 하지만 /home 상위의 폴더는 접근 불가한다.

만약 특정 사용자(root )수준의 ftp 사용자가 /home 상위 이상을 접근하고 싶다면 그 사용자만
$usermod -d ../ 사용자 해주면 모든 디렉토리를 ftp를 통해 접근 가능해 진다.

[리눅스] usermod 명령어



usermod

사용자 계정정보를 수정하는 명령어이다.
기존에 생성되어 있는 계정사용자의 다음과 같은 계정정보들을 수정할 수 있다.

사용형식

       usermod [-c comment] [-d home_dir [ -m]]
               [-e expire_date] [-f inactive_time]
               [-g initial_group] [-G group[,...]]
               [-l login_name] [-p passwd]
               [-s shell] [-u uid [ -o]] [-L|-U] login

사용예 #1

다음은 sspark5라는 계정사용자의 /etc/passwd, /etc/shadow, /etc/group내에 설정된 기본 설정내용이다.

[root@host3 root]# grep sspark5 /etc/passwd
sspark5:x:506:508::/home/sspark5:/bin/bash
[root@host3 root]#
[root@host3 root]# grep sspark5 /etc/shadow
sspark5:$1$/H.bOlGk$jeEdF1g7naK9vVe4v5i/s/:12314:0:99999:7:::
[root@host3 root]#
[root@host3 root]# grep sspark5 /etc/group
sspark5:x:508:
[root@host3 root]#

위의 초기 설정값을 간단히 보면 UID는 506, GID는 508, 코멘트는 현재 없으며, 홈디렉토리는 /home/sspark5이며, 사용하는 기본쉘은 bash쉘임을 알 수 있다.
이제 이 값들을 usermod로 바꾸어 보도록 하자.

먼저, sspark5사용자의 코멘트를 입력해 보자.

[root@host3 root]# usermod -c 박성수 sspark5
[root@host3 root]#

위의 예와 같이 코멘트를 수정하는 usermod의 옵션은 -c이다.

다음은 /etc/passwd내에 sspark5의 변경된 코멘트를 확인한 것이다.

[root@host3 root]# grep sspark5 /etc/passwd
sspark5:x:506:508:박성수:/home/sspark5:/bin/bash
[root@host3 root]#

사용예 #2

이번에는 sspark5사용자의 홈디렉토리를 변경해보자.
usermod에서 홈디렉토리를 변경하는 옵션은 -d이다.

[root@host3 root]# usermod -d /usr/sspark5 sspark5
[root@host3 root]#

위와 같이 홈디렉토리를 변경하였다.

다음은 변경된 값을 확인한 것이다.

[root@host3 root]# grep sspark5 /etc/passwd
sspark5:x:506:508:박성수:/usr/sspark5:/bin/bash
[root@host3 root]#

한가지 주의할 것은 홈디렉토리의 위치가 변경되었지만 원래 있던 홈디렉토리파일들이 삭제되거나 이동되는 것은 아니다.
원래의 홈디렉토리내에 존재하는 파일들은 모두 그대로 존재한다.

사용예 #3

이번에는 -e옵션을 사용하여 sspark5의 계정 종료일을 설정해보자.

[root@host3 root]# usermod -e 2006-12-31 sspark5
[root@host3 root]#

위와 같이 설정한 후에 /etc/shadow파일을 확인한 것이다.
계정 종료일의 설정은 위에서 보았던 /etc/shadow파일의 내용과는 달리 '13513"이 설정되어 있는 거을 알 수가 있다.

[root@host3 root]# grep sspark5 /etc/shadow
sspark5:$1$/H.bOlGk$jeEdF1g7naK9vVe4v5i/s/:12314:0:99999:7::13513:
[root@host3 root]#

사용예 #4

이번에는 sspark5의 기본사용쉘을 변경해 보자.
sspark5의 원래 사용했던 기본사용쉘은 /bin/bash(Bash Shell)이였다.
이것을 usermod로 다음과 같이 /bin/csh(C Shell)로 변경한 것이다.

[root@host3 root]# usermod -s /bin/csh sspark5 
[root@host3 root]#

이를 확인하기 위하여 /etc/passwd의 내용을 확인하였다.

[root@host3 root]# grep sspark5 /etc/passwd
sspark5:x:506:508:박성수:/usr/sspark5:/bin/csh
[root@host3 root]#

사용예 #5

이번에는 sspark5의 UID를 변경해 보자.
UID를 변경하기 위해서는 -u옵션을 사용하면 된다.

[root@host3 root]# usermod -u 508 sspark5    
[root@host3 root]#

원래 sspark5의 UID는 506이였던 것을 508로 변경한 것이다.
다음은 변경된 UID값을 확인한 것이다.

[root@host3 root]# grep sspark5 /etc/passwd
sspark5:x:508:508:박성수:/usr/sspark5:/bin/csh
[root@host3 root]#

이상과 같이 usermod에 대해서 살펴보았다.
usermod명령어는 useradd, useradd -D, userdel과 함께 익혀두는 것이 바람직한다.
여러분들의 건투를 빈다.

2009년 9월 3일 목요일

[리눅스] useradd 옵션



useradd 옵션

-d /user/id --> 홈디렉토리 위치를 /user/id 로 지정함

-u 2000 --> UID 를 2000 으로 지정함

-s /bin/sh --> id 사용자가 기본으로 사용할 쉘 종류를 C쉘로 지정함

-c I'm a man --> 계정사용자의 간단한 코멘트

-e 2009-09-03 --> id의 계정사용기간

-p 1234 --> id의 기본 패스워드

siidc --> 생성할 계정명

1번) useradd -d /home/xnote -u 2000 -s /bin/sh -c NOTEBOOK -e 2007-11-11 -p 1 siidc

ex) useradd -u 1000 -g web -d /user/web -s /bin/sh

2번) useradd에 관한 사용자 생성 및 관리 를 하는 (3개의 파일 _ 디렉토리)

cat /etc/default/useradd--->해당 추가유져 에 대하여 세부적으로 설정가능

cat /etc/login.defs--->메일디렉토리/패스워드기간및알림/UID/GID설정

cat /etc/skel--->계정생성시 자동복사 되는 원본 디렉토리

# useradd defaults file

GROUP=100---> 소속될 그룹의 GID

HOME=/home/web---> 사용자의 홈디렉토리위치

INACTIVE=-1---> 사용자의 패스워드 종료일수 이후의 유효기간

EXPIRE=---> 앞으로 추가 되는 계정들의 종료일수 “2010-10-30” 라고 함

SHELL=/bin/bash---> 기본쉘로 사용할 쉘의 종류이다.

SKEL=/etc/skel---> 새로 생성되는 사용자의 홈디렉토리로 복사될 초기환경파일들이 저장된 디렉토리 지정하는곳

※ 리눅스 는 2번 예제로 설정하는 것보다 1번 예제로 설정하였는것 을 우선으로 함! ※
\

2009년 8월 24일 월요일

[펌] [포토샵 CS4] 포토샵 CS4 한글패치



영문판을 설치하고 심심해서 한글패치를 해봤더니
다시 영문으로 돌리는 법을 찾아도 인터넷상에 열심히 찾았는데 없더군요
열심히 삽질한결과 덕분에 한영 전환법도 알게되었네요.
의외로 간단하네요





실행법은
1.CS4 영문판으로 설치
2.한글 패치파일로 한글패치를 한다.
3.아래의 위치로 이동한다.( 2개의 폴더가 있습니다.)



3.아래 위치에서 pack.inf 파일을 열어 아래와 같이 수정합니다.


4.아래 위치에서 tw10428.dat 파일을 삭제합니다.




5. 완료 설정 창에서 한국어와 영어 사용할수 있습니다.
   원하는 언어로 선택후 포토샵을 다시 켜시면 됩니다.



- cs4에 설정 메뉴에 변화가 많아 설정법도 좀 바꾸고 바쁘네요.
※ 참고
- cs3이전의 zoom모드로 변환하는 법
Preferences / General 에서 Zoom Resize Windows 체크를 끄면
이전과 같이 Ctrl +  +,-  에서 창은 줄어들지 않네요.이것땜에 많이 헷갈렸다는...
- 이미지마다 새창 띄우기
 위화면의 Open Documents as Taps 에 체크를 끄면 이전과 같이 오픈 시킬때 창으로 띄울수있습니다.
탐색기에서 끌어오는 것은 안되구요..

펌 - 출처 : http://radsaga.tistory.com/94