function insert_point($mb_id, $point, $content='', $rel_table='', $rel_id='', $rel_action='')
{
global $config;
global $g4;
global $is_admin;
// 포인트 사용을 하지 않는다면 return
if (!$config[cf_use_point]) { return 0; }
// 포인트가 없다면 업데이트 할 필요 없음
if ($point == 0) { return 0; }
// 회원아이디가 없다면 업데이트 할 필요 없음
if ($mb_id == "") { return 0; }
$mb = sql_fetch(" select mb_id from $g4[member_table] where mb_id = '$mb_id' ");
if (!$mb[mb_id]) { return 0; }
// 이미 등록된 내역이라면 건너뜀
if ($rel_table || $rel_id || $rel_action)
{
if ($rel_table == "@login") {} else { // 로그인테이블의 경우에는 등록된 내역 확인을 생략
$sql = " select count(*) as cnt from $g4[point_table]
where mb_id = '$mb_id'
and po_rel_table = '$rel_table'
and po_rel_id = '$rel_id'
and substring(po_datetime,1,10) = '$g4[time_ymd]'
and po_rel_action = '$rel_action' ";
$row = sql_fetch($sql);
if ($row[cnt])
return -1;
} // 추가된 if 문 닫기
}
$sql="select sum(po_point) as today_point from $g4[point_table]
where mb_id = '$mb_id' and po_rel_table != '@passive'
and substring(po_datetime,1,10) = '$g4[time_ymd]'";
$reset = sql_fetch("select max(po_id) as max_po_id from $g4[point_table] where mb_id='$mb_id' and po_rel_table='@reset'");
if($reset[max_po_id]) $sql .= " and po_id > $reset[max_po_id]";
// 1일 포인트 적용양을 1000으로 제한(관리자가 주는것 제외)
$today_point = sql_fetch($sql);
if($is_admin != 'super' && $today_point[today_point] >= 1000) return 0;
if($is_admin != 'super' && ($today_point[today_point] + $point) >= 1000) $point = 1000 - $today_point[today_point];
// 포인트 건별 생성
$sql = " insert into $g4[point_table]
set mb_id = '$mb_id',
po_datetime = '$g4[time_ymdhis]',
po_content = '".addslashes($content)."',
po_point = '$point',
po_rel_table = '$rel_table',
po_rel_id = '$rel_id',
po_rel_action = '$rel_action' ";
sql_query($sql);
// 포인트 내역의 합을 구하고
$sql = " select sum(po_point) as sum_po_point from $g4[point_table] where mb_id = '$mb_id' ";
$row = sql_fetch($sql);
$sum_point = $row[sum_po_point];
// 포인트 UPDATE
$sql = " update $g4[member_table] set mb_point = '$sum_point' where mb_id = '$mb_id' ";
sql_query($sql);
return 1;
}
여기에 어디에다 DB 커넥션 코드를 넣어야 하나요? 도무지 모르겠어요 그리고 DB 커넥션 코드도 알려주세요