그누5 포인트별 레벨 아이콘이 손님으로만 뜹니다.
본문
참조한 게시물은
https://sir.kr/g5_tip/7638 그리고 https://sir.kr/cm_free/1457865 입니다.
게시판 주소는 http://zerochoice.dothome.co.kr/guest/bbs/board.php?bo_table=free&page=1 인데,
포인트별로 레벨 아이콘이 변경되도록 하려고 파일을 작성했는데, 결과값이 손님 아이콘으로만 고정되어있는 상태입니다.
common.lib.php 파일은
http://zerochoice.dothome.co.kr/guest/lib/common.lib.php 입니다.
중간의 "2147483647"
있는 부분은 추가로 입력한 권한별 아이콘 생성 구문인데 그부분은 정상 작동합니다.
5시간째 해답이 나오지 않는 상황입니다... 무엇이 잘못되었는지 고수님들의 고견 기다립니다.
감사합니다. 사용 그누보드5 버전은 가장 최신 버전입니다.
// 포인트 부여
function insert_point($mb_id, $point, $content='', $rel_table='', $rel_id='', $rel_action='', $expire=0)
{
global $config;
global $g5;
global $is_admin;
global $levelinfo;
$levelinfo = array(
"1" => array("name" => "Level 1","min" => "0","max" => "1000"),
"2" => array("name" => "Level 2","min" => "1000","max" => "3000"),
"3" => array("name" => "Level 3","min" => "3000","max" => "6000"),
"4" => array("name" => "Level 4","min" => "6000","max" => "10000"),
"5" => array("name" => "Level 5","min" => "10000","max" => "15000"),
"6" => array("name" => "Level 6","min" => "15000","max" => "21000"),
"7" => array("name" => "Level 7","min" => "21000","max" => "28000"),
"8" => array("name" => "Level 8","min" => "28000","max" => "36000"),
"9" => array("name" => "Level 9","min" => "36000","max" => "45000"),
"10" => array("name" => "Level 10","min" => "45000","max" => "55000"),
"11" => array("name" => "Level 11","min" => "55000","max" => "66000"),
"12" => array("name" => "Level 12","min" => "66000","max" => "78000"),
"13" => array("name" => "Level 13","min" => "78000","max" => "91000"),
"14" => array("name" => "Level 14","min" => "91000","max" => "105000"),
"15" => array("name" => "Level 15","min" => "105000","max" => "120000"),
"16" => array("name" => "Level 16","min" => "120000","max" => "136000"),
"17" => array("name" => "Level 17","min" => "136000","max" => "153000"),
"18" => array("name" => "Level 18","min" => "153000","max" => "171000"),
"19" => array("name" => "Level 19","min" => "171000","max" => "190000"),
"20" => array("name" => "Level 20","min" => "190000","max" => "210000"),
"21" => array("name" => "Level 21","min" => "210000","max" => "231000"),
"22" => array("name" => "Level 22","min" => "231000","max" => "253000"),
"23" => array("name" => "Level 23","min" => "253000","max" => "276000"),
"24" => array("name" => "Level 24","min" => "276000","max" => "300000"),
"25" => array("name" => "Level 25","min" => "300000","max" => "325000"),
"26" => array("name" => "Level 26","min" => "325000","max" => "351000"),
"27" => array("name" => "Level 27","min" => "351000","max" => "378000"),
"28" => array("name" => "Level 28","min" => "378000","max" => "406000"),
"29" => array("name" => "Level 29","min" => "406000","max" => "435000"),
"30" => array("name" => "Level 30","min" => "435000","max" => "465000"),
"31" => array("name" => "Level 31","min" => "465000","max" => "496000"),
"32" => array("name" => "Level 32","min" => "496000","max" => "528000"),
"33" => array("name" => "Level 33","min" => "528000","max" => "561000"),
"34" => array("name" => "Level 34","min" => "561000","max" => "595000"),
"35" => array("name" => "Level 35","min" => "595000","max" => "630000"),
"36" => array("name" => "Level 36","min" => "630000","max" => "666000"),
"37" => array("name" => "Level 37","min" => "666000","max" => "703000"),
"38" => array("name" => "Level 38","min" => "703000","max" => "741000"),
"39" => array("name" => "Level 39","min" => "741000","max" => "780000"),
"40" => array("name" => "Level 40","min" => "780000","max" => "820000"),
"41" => array("name" => "Level 41","min" => "820000","max" => "861000"),
"42" => array("name" => "Level 42","min" => "861000","max" => "903000"),
"43" => array("name" => "Level 43","min" => "903000","max" => "946000"),
"44" => array("name" => "Level 44","min" => "946000","max" => "990000"),
"45" => array("name" => "Level 45","min" => "990000","max" => "1035000"),
"46" => array("name" => "Level 46","min" => "1035000","max" => "1081000"),
"47" => array("name" => "Level 47","min" => "1081000","max" => "1128000"),
"48" => array("name" => "Level 48","min" => "1128000","max" => "1176000"),
"49" => array("name" => "Level 49","min" => "1176000","max" => "1225000"),
"50" => array("name" => "Level 50","min" => "1225000","max" => "1275000"),
"51" => array("name" => "Level 51","min" => "1275000","max" => "1326000"),
"52" => array("name" => "Level 52","min" => "1326000","max" => "1378000"),
"53" => array("name" => "Level 53","min" => "1378000","max" => "1431000"),
"54" => array("name" => "Level 54","min" => "1431000","max" => "1485000"),
"55" => array("name" => "Level 55","min" => "1485000","max" => "1540000"),
"56" => array("name" => "Level 56","min" => "1540000","max" => "1596000"),
"57" => array("name" => "Level 57","min" => "1596000","max" => "1653000"),
"58" => array("name" => "Level 58","min" => "1653000","max" => "1711000"),
"59" => array("name" => "Level 59","min" => "1711000","max" => "1770000"),
"60" => array("name" => "Level 60","min" => "1770000","max" => "1830000"),
"61" => array("name" => "Level 61","min" => "1830000","max" => "1891000"),
"62" => array("name" => "Level 62","min" => "1891000","max" => "1953000"),
"63" => array("name" => "Level 63","min" => "1953000","max" => "2016000"),
"64" => array("name" => "Level 64","min" => "2016000","max" => "2080000"),
"65" => array("name" => "Level 65","min" => "2080000","max" => "2145000"),
"66" => array("name" => "Level 66","min" => "2145000","max" => "2211000"),
"67" => array("name" => "Level 67","min" => "2211000","max" => "2278000"),
"68" => array("name" => "Level 68","min" => "2278000","max" => "2346000"),
"69" => array("name" => "Level 69","min" => "2346000","max" => "2415000"),
"70" => array("name" => "Level 70","min" => "2415000","max" => "2485000"),
"71" => array("name" => "Level 71","min" => "2485000","max" => "2556000"),
"72" => array("name" => "Level 72","min" => "2556000","max" => "2628000"),
"73" => array("name" => "Level 73","min" => "2628000","max" => "2701000"),
"74" => array("name" => "Level 74","min" => "2701000","max" => "2775000"),
"75" => array("name" => "Level 75","min" => "2775000","max" => "2850000"),
"76" => array("name" => "Level 76","min" => "2850000","max" => "2926000"),
"77" => array("name" => "Level 77","min" => "2926000","max" => "3003000"),
"78" => array("name" => "Level 78","min" => "3003000","max" => "3081000"),
"79" => array("name" => "Level 79","min" => "3081000","max" => "3160000"),
"80" => array("name" => "Level 80","min" => "3160000","max" => "3240000"),
"81" => array("name" => "Level 81","min" => "3240000","max" => "3321000"),
"82" => array("name" => "Level 82","min" => "3321000","max" => "3403000"),
"83" => array("name" => "Level 83","min" => "3403000","max" => "3486000"),
"84" => array("name" => "Level 84","min" => "3486000","max" => "3570000"),
"85" => array("name" => "Level 85","min" => "3570000","max" => "3655000"),
"86" => array("name" => "Level 86","min" => "3655000","max" => "3741000"),
"87" => array("name" => "Level 87","min" => "3741000","max" => "3828000"),
"88" => array("name" => "Level 88","min" => "3828000","max" => "3916000"),
"89" => array("name" => "Level 89","min" => "3916000","max" => "4005000"),
"90" => array("name" => "Level 90","min" => "4005000","max" => "4095000"),
"91" => array("name" => "Level 91","min" => "4095000","max" => "4186000"),
"92" => array("name" => "Level 92","min" => "4186000","max" => "4278000"),
"93" => array("name" => "Level 93","min" => "4278000","max" => "4371000"),
"94" => array("name" => "Level 94","min" => "4371000","max" => "4465000"),
"95" => array("name" => "Level 95","min" => "4465000","max" => "4560000"),
"96" => array("name" => "Level 96","min" => "4560000","max" => "4656000"),
"97" => array("name" => "Level 97","min" => "4656000","max" => "4753000"),
"98" => array("name" => "Level 98","min" => "4753000","max" => "4851000"),
"99" => array("name" => "Level 99","min" => "4851000","max" => "4950000"),
"100" => array("name" => "Level 100","min" => "990000","max" => "1010000"),
"101" => array("name" => "Level 101","min" => "1010000","max" => "1030200"),
"102" => array("name" => "Level 102","min" => "1030200","max" => "1050600"),
"103" => array("name" => "Level 103","min" => "1050600","max" => "1071200"),
"104" => array("name" => "Level 104","min" => "1071200","max" => "1092000"),
"105" => array("name" => "Level 105","min" => "1092000","max" => "1113000")
);
// 포인트 사용을 하지 않는다면 return
[중략]
// 포인트 UPDATE
$sql = " update {$g5['member_table']} set mb_point = '$po_mb_point' where mb_id = '$mb_id' ";
sql_query($sql);
// 포인트에 따라 권한 자동 올리기
$mb_level = sql_fetch(" select mb_level from {$g5['member_table']} where mb_id = '$mb_id' ");
if($mb_level['mb_level'] < 10){
if($po_mb_point < 2000){ //2000 포인트 미만이면 권한 2
$level_up = 2;
}elseif($po_mb_point < 3000){
$level_up = 3;
}elseif($po_mb_point < 5000){
$level_up = 4;
}elseif($po_mb_point < 9000){
$level_up = 5;
}elseif($po_mb_point < 15000){
$level_up = 6;
}elseif($po_mb_point < 30000){
$level_up = 7;
}elseif($po_mb_point < 50000){
$level_up = 8;
}elseif($po_mb_point < 2147483647){
$level_up = 9;
}
sql_query(" update {$g5['member_table']} set mb_level = '$level_up' where mb_id = '$mb_id' ");
}
$member_level = get_level_info($member['mb_id']);
return 1;
}
// 포인트를 통한 레벨 가져오기
function get_level_from_point($mb_id) {
global $levelinfo;
///레벨별 최소 포인트
$levelinfo = array(
'1' => 0
, '2' => 1000
, '3' => 3000
, '4' => 5000
, '5' => 10000
);
// 포인트별 레벨 찾기
foreach($levelinfo as $level => $lvinfo) {
if($point < $lvinfo)
break;
$r_level = $level;
}
$mb = get_member($mb_id, "mb_level, mb_id, mb_point");
$point = $mb['mb_point'];
$r_level = 1;
foreach($levelinfo as $level => $lvinfo) {
if(!$lvinfo['min'] && $point > $lvinfo['max']) {
$r_level = 1;
} else if($point >= $lvinfo['min'] && $point < $lvinfo['max']) {
$r_level = $level;
break;
}
}
return Array($mb['mb_level'], $r_level, $point);
}
function get_level_info($mb_id) {
global $levelinfo, $levelset;
if($mb_id && $mb_id != 'guest') {
$pinfo = get_level_from_point($mb_id);
$level = $pinfo[1];
$level_point = $pinfo[2];
$lvinfo = $levelinfo[$level];
$bar_len = $lvinfo['max'] - $lvinfo['min'];
$lv_len = $level_point - $lvinfo['min'];
$ratio = ($lv_len/$bar_len)*100;
$lvinfo = $levelinfo[$level];
$lvinfo['level'] = $level;
$is_admin = is_admin($mb_id);
if ($is_admin == 'super') {
$lvinfo['ratio'] = 100;
$lvinfo['icon'] = "<img src='".G5_IMG_URL."/lvl/admin.gif' align='absmiddle' title='관리자'>";
} else {
$lvinfo['ratio'] = ceil($ratio*100)/100;
$lvinfo['icon'] = "<img src='".G5_IMG_URL."/lvl/".$level.".gif' align='absmiddle' title='포인트레벨 ".$level."".number_format($level_point)."점'>";
}
} else {
$lvinfo['gnu_name'] = 'guest';
$lvinfo['level'] = 0;
$lvinfo['ratio'] = rand(30, 100);
$lvinfo['icon'] = "<img src='".G5_IMG_URL."/lvl/guest.gif' align='absmiddle' title='손님'>";
}
return $lvinfo;
}
// 사용포인트 입력
답변을 작성하시기 전에 로그인 해주세요.