완료시 특정필드 가리기
본문
상담완료시엔 전화번호가 모두 오픈되고
상담신청중,상담중일땐 레벨 5이상부터만 뒷자리를 보이게하고싶습니다.
방법좀 알려주세요 ㅠㅠㅠㅠ
list.php의 전화번호칸
<?php
for ($i=0; $i<count($list); $i++) {
if ($list[$i]['wr_6']) { // 전화번호 필드에 값이 있으면
if ($member['mb_level'] >= 5) // 회원 레벨이 5 이면
$hp = $list[$i]['wr_6'];
else // 회원 레벨 5가 아니거나, 비회원이라면
$hp = substr($list[$i]['wr_6'], 0, -4) . "****";
$hp_hyphen = preg_replace("/(0(?:2|[0-9]{2}))([0-9\*]+)([0-9]{4}$)/", "\\1-\\2-\\3", $hp); // 하이픈 정규식 처리
}
write.skin.php의 상담신청 체크버튼 부분 소스
<? if($w == 'u') { ?>
<tr>
<th><label for="wr_4" > 상담신청</label></th>
<td colspan="3">
<select name="wr_5" style="width:100%; padding-left: 11px;">
<option value="<span class='wr_5_btn wr_5_1'>상담신청</span>" <?php if($wr_5 =="상담신청") echo "selected=\"selected\""; ?>>상담신청</option>
<option value="<span class='wr_5_btn wr_5_2'>상담 중 </span>" <?php if($wr_5 == "상담 중 ") echo "selected=\"selected\""; ?>>상담 중 </option>
<option value="<span class='wr_5_btn wr_5_3'>상담완료</span>" <?php if($wr_5 == "상담완료") echo "selected=\"selected\""; ?>>상담완료</option>
</select></td>
</tr>
<?php } ?>
답변 5
<?php
for ($i=0; $i<count($list); $i++) {
if ($list[$i]['wr_5']=="상담완료") { // 회원 레벨이 5 이거나, 상담완료일때
$hp = $list[$i]['wr_6'];
$hp_hyphen = preg_replace("/(0(?:2|[0-9]{2}))([0-9\*]+)([0-9]{4}$)/", "\\1-\\2-\\3", $hp); // 하이픈 정규식 처리
} else if ($member['mb_level'] >= 5) { // 회원 레벨이 5 이거나, 상담완료일때
$hp = $list[$i]['wr_6'];
$hp_hyphen = preg_replace("/(0(?:2|[0-9]{2}))([0-9\*]+)([0-9]{4}$)/", "\\1-\\2-\\3", $hp); // 하이픈 정규식 처리
} else {
$hp = substr($list[$i]['wr_6'], 0, -4) . "****";
$hp_hyphen = $hp;
}
if ($list[$i]['wr_6']) { // 전화번호 필드에 값이 있으면
if ($member['mb_level'] >= 5) // 회원 레벨이 5 이면
$hp = $list[$i]['wr_6'];
else // 회원 레벨 5가 아니거나, 비회원이라면
$hp = substr($list[$i]['wr_6'], 0, -4) . "****";
를 아래와 같이 변경하세요
if ($list[$i]['wr_5']=="상담완료" || $member['mb_level'] >= 5) // 회원 레벨이 5 이면
$hp = $list[$i]['wr_6'];
} else {
$hp = substr($list[$i]['wr_6'], 0, -4) . "****";
}
기호 하나가 빠졌었네요
if ($list[$i]['wr_5']=="상담완료" || $member['mb_level'] >= 5) { // 회원 레벨이 5 이거나, 상담완료일때
$hp = $list[$i]['wr_6'];
} else {
$hp = substr($list[$i]['wr_6'], 0, -4) . "****";
}
상담완료일때는 모두(비회원 포함)에게 전화번호 전체가 보입니다.
상담완료가 아닐때는 레벨5 이상이면 전화번호 전체가 보입니다.
if ($list[$i]['wr_5']=="상담완료" || $member['mb_level'] >= 5) { // 회원 레벨이 5 이거나, 상담완료일때
$hp = $list[$i]['wr_6'];
$hp_hyphen = preg_replace("/(0(?:2|[0-9]{2}))([0-9\*]+)([0-9]{4}$)/", "\\1-\\2-\\3", $hp); // 하이픈 정규식 처리
} else {
$hp = substr($list[$i]['wr_6'], 0, -4) . "****";
$hp_hyphen = $hp;
}
붙일곳에는 <?php echo $hp_hyphen; ?> 이렇게 해보세요
view.skin.php 에서는 이렇게 사용하면 되겠죠...
<?php
if ($view['wr_5']=="<span class='wr_5_btn wr_5_3'>상담완료</span>") { // 회원 레벨이 5 이거나, 상담완료일때
$hp = $view['wr_6'];
$hp_hyphen = preg_replace("/(0(?:2|[0-9]{2}))([0-9\*]+)([0-9]{4}$)/", "\\1-\\2-\\3", $hp); // 하이픈 정규식 처리
} else if ($member['mb_level'] >= 5) { // 회원 레벨이 5 이거나, 상담완료일때
$hp = $view['wr_6'];
$hp_hyphen = preg_replace("/(0(?:2|[0-9]{2}))([0-9\*]+)([0-9]{4}$)/", "\\1-\\2-\\3", $hp); // 하이픈 정규식 처리
} else {
$hp = substr($view['wr_6'], 0, -4) . "****";
$hp_hyphen = $hp;
}
?>