<?php class MemberClass { //회원 신규 입력 function MemberRegister($arr){ date_default_timezone_set('Asia/Seoul'); $rs=$this->MemberIDCheck($arr['idx'],$arr['userID']); //아이디중복검사 if($rs<0){ //아이디 중복 return -1; exit; } else if($rs==1){ //아이디 입력가능 $sql="insert into member (idx,userID,passwd,userNM,telNO,mobileNO,email,Cate1,Cate2,smart,"; if(isset($arr['positionNM'])) $sql.="positionNM,"; $sql.="allowLogin,regdate) values(NULL,"; $sql.="'".$arr['userID']."',"; $sql.="md5('".substr($arr['mobileNO'],-4)."'),"; $sql.="'".$arr['userNM']."',"; $sql.="'".$this->SplitRemove($arr['telNO'])."',"; $sql.="'".$this->SplitRemove($arr['mobileNO'])."',"; $sql.="'".$arr['email']."',"; $sql.="'".$arr['Cate1']."',"; $sql.="'".$arr['Cate2']."',"; $sql.="'".$arr['smart']."',"; if(isset($arr['positionNM'])) // 변수가 있으면 추가하라 $sql.="'".$arr['positionNM']."',"; $sql.="'".$arr['allowLogin']."',"; $sql.="'".date("Ymd")."'"; // 등록일자 if($result=mysql_query($sql)){ return mysql_insert_id(); } else { return $sql; }
} else {//알수없는 Db오류 return $sql; } }
//회원정보 수정 function MemberModify($arr){ global $db; date_default_timezone_set('Asia/Seoul');
$rs=$this->MemberIDCheck($arr['idx'],$arr['userID']); if($rs<0){ //아이디 중복 return -1; exit; } else if($rs==1){ //아이디 입력가능 $sql="update member set "; $sql.="userID='".$arr['userID']."',"; if(isset($arr['passwd'])){ $sql.="passwd=md5('".$arr['passwd']."'),"; } $sql.="userNM='".$arr['userNM']."',"; $sql.="telNO='".$this->SplitRemove($arr['telNO'])."',"; $sql.="mobileNO='".$this->SplitRemove($arr['mobileNO'])."',"; $sql.="email='".$arr['email']."',"; $sql.="Cate1='".$arr['Cate1']."',"; $sql.="Cate2='".$arr['Cate2']."',"; $sql.="smart='".$arr['smart']."',"; if(isset($arr['positionNM'])){ $sql.="positionNM='".$arr['positionNM']."',"; } if(isset($arr['allowLogin'])){ $sql.="allowLogin='".$arr['allowLogin']."',"; } if(isset($arr['hidden'])){ $sql.="hidden='".$arr['hidden']."',"; } $sql.="regdate='".date("Ymd")."'"; // 수정일자 $sql.=" where idx=".$arr['idx']; if($result=mysql_query($sql)){ return $arr['idx']; } else { return $sql; }
} else {//알수없는 Db오류 return 0; }
} //end function
//회원정보 삭제 function MemberDelete($idx){ global $db; $sql="delete from member where idx=".$idx; if($result=mysql_query($sql)){ return 1; } else { return $sql; } }
//변경전 로그인ID 유일성체크 function MemberIDCheck($idx,$userID){ global $db; $sql="select idx,count(*) from member where userID='".$userID."'"; if($result=mysql_query($sql)){ $row=mysql_fetch_row($result); if($row[1]==1){ //id존재 if($row[0]==$idx){ // id변경없음 return 1; } else { //id변경시도, 다른 id존재, 변경불가 return -1; } } else { //변경시도, 다른id없음, 변경가능 return 1; } } else { return 0; } }
} ?> |