select 및 radio 버튼 기억하기

안녕하세요..
회원가입이라든지 기타 입력값을 받을때 select 혹은 radio 버튼으로 구성되어 있는 폼에서
수정화면을 보여줘야 할경우 기존에 선택했던 값들을 보여주게 됩니다.
다음과 같이 자바스크립트 코드를 삽입한뒤에 document.onload 를 이용해
입력시 선택했던것들이 선택되게 해봤습니다..

:
:

SMTP ?????

/* 파일명 : class.Smtp.php
/* 제작일 : 2002-08-30
/* 제작자 : 하근호(hopegiver@korea.com)
/***************************************/

class Smtp {

var $host;
var $fp;
var $self;
var $lastmsg;
var $parts;
var $error;
var $debug;
var $charset;
var $ctype;

function Smtp($host=”localhost”) {
if($host == “self”) $this->self = true;
else $this->host = $host;
$this->parts = array();
$this->error = array();
$$this->debug = 0;
$this->charset = “euc-kr”;
$this->ctype = “text/html”;
}

// 디버그 모드 : 1
function debug($n=1) {
$this->debug = $n;
}

// smtp 통신을 한다.
function dialogue($code, $cmd) {

fputs($this->fp, $cmd.”
“);
$line = fgets($this->fp, 1024);
ereg(“^([0-9]+).(.*)$”, $line, &$data);
$this->lastmsg = $data[0];

if($this->debug) {
echo htmlspecialchars($cmd).”
“.$this->lastmsg.”
“;
flush();
}

if($data[1] != $code) return false;
return true;

}

// smptp 서버에 접속을 한다.
function smtp_connect($host) {

if($this->debug) {
echo “SMTP($host) Connecting…
“;
flush();
}

if(!$host) $host = $this->host;
if(!$this->fp = fsockopen($host, 25, $errno, $errstr, 10)) {
$this->lastmsg = “SMTP($host) 서버접속에 실패했습니다.[$errno:$errstr]”;
return false;
}

$line = fgets($this->fp, 1024);
ereg(“^([0-9]+).(.*)$”, $line, &$data);
$this->lastmsg = $data[0];
if($data[1] != “220”) return false;

if($this->debug) {
echo $this->lastmsg.”
“;
flush();
}

$this->dialogue(250, “HELO phpmail”);
return true;

}

// stmp 서버와의 접속을 끊는다.
function smtp_close() {

$this->dialogue(221, “QUIT”);
fclose($this->fp);
return true;

}

// 메시지를 보낸다.
function smtp_send($email, $from, $data) {

if(!$mail_from = $this->get_email($from)) return false;
if(!$rcpt_to = $this->get_email($email)) return false;

if(!$this->dialogue(250, “MAIL FROM: $mail_from”))
$this->error[] = $email.”:MAIL FROM 실패($this->lastmsg)”;
if(!$this->dialogue(250, “RCPT TO: $rcpt_to”))
$this->error[] = $email.”:RCPT TO 실패($this->lastmsg)”;
$this->dialogue(354, “DATA”);

$mime = “Message-ID: <".$this->get_message_id().”>
“;
$mime .= “From: $from
“;
$mime .= “To: $email
“;

fputs($this->fp, $mime);
fputs($this->fp, $data);
$this->dialogue(250, “.”);

}

// Message ID 를 얻는다.
function get_message_id() {
$id = date(“YmdHis”,time());
mt_srand((float) microtime() * 1000000);
$randval = mt_rand();
$id .= $randval.”@phpmail”;
return $id;
}

// Boundary 값을 얻는다.
function get_boundary() {
$uniqchr = uniqid(time());
$one = strtoupper($uniqchr[0]);
$two = strtoupper(substr($uniqchr,0,8));
$three = strtoupper(substr(strrev($uniqchr),0,8));
return “—-=_NextPart_000_000${one}_${two}.${three}”;
}

// 첨부파일이 있을 경우 이 함수를 이용해 파일을 첨부한다.
function attach($message, $name=””, $ctype=”application/octet-stream”) {
$this->parts[] = array (“ctype” => $ctype, “message” => $message, “name” => $name);
}

// Multipart 메시지를 생성시킨다.
function build_message($part) {

$msg .= “Content-Type: “.$part[‘ctype’];
if($part[‘name’]) $msg .= “; name=””.$part[‘name’].”””;
$msg .= “
Content-Transfer-Encoding: base64
“;
$msg .= “Content-Disposition: attachment; filename=””.$part[‘name’].””

“;
$msg .= chunk_split(base64_encode($part[‘message’]));
return $msg;

}

// SMTP에 보낼 DATA를 생성시킨다.
function build_data($subject, $body) {

$boundary = $this->get_boundary();

$mime .= “Subject: $subject
“;
$mime .= “Date: “.date (“D, j M Y H:i:s T”,time()).”
“;
$mime .= “MIME-Version: 1.0
“;
$mime .= “Content-Type: multipart/mixed; boundary=””.$boundary.””

“.
“This is a multi-part message in MIME format.

“;
$mime .= “–“.$boundary.”
“.
“Content-Type: “.$this->ctype.”; charset=””.$this->charset.””
“.
“Content-Transfer-Encoding: base64

“.
chunk_split(base64_encode($body)).

–“.$boundary;

$max = count($this->parts);
for($i=0; $i<$max; $i++) {
$mime .= “
“.$this->build_message($this->parts[$i]).”

–“.$boundary;
}
$mime .= “–
“;

return $mime;

}

// MX 값을 찾는다.
function get_mx_server($email) {

if(!ereg(“([._0-9a-zA-Z-]+)@([0-9a-zA-Z-]+.[a-zA-Z.]+)”, $email, $reg)) return false;
getmxrr($reg[2], $host);
if(!$host) $host[0] = $reg[2];
return $host;

}

// 이메일의 형식이 맞는지 체크한다.
function get_email($email) {
if(!ereg(“([._0-9a-zA-Z-]+)@([0-9a-zA-Z-]+.[a-zA-Z.]+)”, $email, $reg)) return false;
return “<".$reg[0].">“;
}

// 메일을 전송한다.
function send($to, $from, $subject, $body) {

if(!is_array($to)) $to = split(“[,;]”,$to);
if($this->self) {

$data = $this->build_data($subject, $body);
foreach($to as $email) {
if($host = $this->get_mx_server($email)) {
$flag = false; $i = 0;
while($flag == false) {
if($host[$i]) {
$flag = $this->smtp_connect($host[$i]);
$i++;
} else break;
}
if($flag) {
$this->smtp_send($email, $from, $data);
$this->smtp_close();
} else {
$this->error[] = $email.”:SMTP 접속실패”;
}
} else {
$this->error[] = $email.”:형식이 잘못됨”;
}
}

} else {

if(!$this->smtp_connect($this->host)) {
$this->error[] = “$this->host SMTP 접속실패”;
return false;
}
$data = $this->build_data($subject, $body);
foreach($to as $email) $this->smtp_send($email, $from, $data);
$this->smtp_close();

}

}

}

/* 사용법
$mail = new Smtp(“self”);
$mail->debug();
$mail->send(“photon0@hanmail.net”, “hopegiver@whois.co.kr”, “이 메일은 정상입니다.”, “정상적인 메일이니 삭제하지 마십시오.”);
*/

?>

항상 리프레쉬 되게 하기

일반적으로 게시판등의 동적인 사이트인 경우에 항상 리프레쉬되게 하기 위해서 PHP나 HTML에서 여러가지 Header값을 사용하지요.
그런데 이상하게되 자꾸 리프레쉬가 않되고 캐쉬에서 불러오는 경우가 있습니다.
고칠수도 이유를 찾을수도 없는 경우 참 갑갑하지요.
똑같은 셋팅에 스크립트가 어떤 서버에서 작동할 때만 리프레쉬가 않된다거나, 또는 특정 사용자, 특정 브라우저에서만 자꾸 캐쉬에서 읽어올 때 갑갑함이 더합니다.
이럴때 확실하게 리프레쉬 시키는 방법입니다.

* 필요한 함수
function append_tic($url) {
return $url . (strpos($url, ‘?’) ? ‘&' : ‘?’ ) . “tic=” . time();
}

* 사용방법 예
“>게시판가기
“>관리자모드

매 초마다 브라우저에서 인식하는 url주소가 달라지기 때문에 절대로 캐쉬에서 불러오지 못합니다.

음.. 혹시 일초안에 두번 이동하면 어떻게 되냐고 따지시고 싶으신분들… time() 대신에 microtime() 쓰세요. -_-;;

onError 이벤트를 이용한 업로드전 이미지 미리보기

방금전에 msdn 보다가 onError 이벤트를 우연히 보게됐는데 몇가지 이용할만한게 생각이 나더군요.
그 중에 업로드전 이미지 미리보기를 만들어서 올려봅니다.
검색해보니 업로드전 이미지 미리보기가 올라온게 있긴한데 이쪽이 더 좋지 않나 싶네요.
이건 확장자에 상관없이 이미지 파일이면 무조건 보여주거든요.
보여드리는데 중점을 둔거라 조잡해도 이해해 주세요.

echo”


ORO





“;
?>

작은 달력 표시하기

//* calendar 용..

//표시하고자 하는 월 값 초기화
$cur_date = isset($cur_date) ? strtotime($cur_date) : time();

//요일의 시작을 설정(일요일이면 0, 월요일이면 1)
$start_dayofweak = 0;//0-sunday , 1-monday

//달력정보 : 달력에서 표시하는 첫날과 마지막날의 정보
$calendar = getCalendarInfo($cur_date,$start_dayofweak);
$day_term = 60*60*24;

//전월과 다음월 : 링크위해 사용
$before_cur_date = date(“Y-m-d”,mktime(0,0,0,date(“m”,$cur_date)-1,1,date(“Y”,$cur_date)));
$next_cur_date = date(“Y-m-d”,mktime(0,0,0,date(“m”,$cur_date)+1,1,date(“Y”,$cur_date)));

echo ”

“;
for($i = 0;$i<7;$i++) echo "

“;
echo “

“;

$disp_type = 0; //0:no month, 1:with month
$_disp_month = 0;

$_cnt = 0;
while(1){
//표시할 날짜
$display_date = intval($calendar[startdate]+$_cnt*$day_term);

//색깔
switch(strftime(“%w”,$display_date)){
case 0: //sun
$fontstyle = ““;break;
case 6://sat
$fontstyle = ““;break;
default:
$fontstyle = ““;break;
}
if(date(“m”,$cur_date)!=date(“m”,$display_date))
$fontstyle = ““;

if(strtotime(date(“Y-m-d”)) == $display_date) $fontstyle.=”“;

//출력
if(!$_disp_month):
$date_str = date(“m/d”,$display_date);
$_disp_month = true;
else:
if(intval(date(“d”,$display_date)) == 1) {
$date_str = date(“m/d”,$display_date);
} else {
$date_str = date(“d”,$display_date);
}
endif;

echo sprintf(“%s

%s”,(($_cnt%7 == 0) ? “

” : “”),$fontstyle,$date_str,((!$_cnt%7 == 6) ? “

” : “”));

if($display_date==$calendar[enddate]) break;

$_cnt++;
}

//* 해당월 달력정보
function getCalendarInfo($date,$start_dayofweak = 0){

$_date = is_numeric($date) ? $date : strtotime($date);

$info = array();
//그달의 첫날
$info[firstdate] = mktime(0,0,0,date(“m”,$_date),1,date(“Y”,$_date));
//그달의 마지막날
$info[lastdate] = mktime(0,0,0,date(“m”,$_date)+1,0,date(“Y”,$_date));
//달력시작일
$info[startdate] = $info[firstdate] + 60*60*24*intval($start_dayofweak-strftime(“%w”,$info[firstdate]));
//달력종료일
$info[enddate] = $info[lastdate] + 60*60*24*intval($start_dayofweak-strftime(“%w”,$info[lastdate])+6);
return $info;
}
?>

© 2025 갤러리 POMODORO - 테마: Patus 제작자 FameThemes.
“.strftime(‘%B, %Y’,$cur_date).”
<  
>
“.substr(date(“l”,intval($calendar[startdate]+$i*$day_term)),0,1).”
%s%s