포인트가 서버들 끼리 잘 안올라가요~ 채택완료
그누매너냐
11년 전
조회 4,443
01 |
if($domain) { |
02 |
$connect_db2 = sql_connect(${'mysql_host_'.$domain}, ${'mysql_user_'.$domain}, ${'mysql_password_'.$domain}); |
03 |
$select_db2 = sql_select_db(${'mysql_db_'.$domain}, $connect_db2); |
04 |
if(!$select_db2) exit; |
05 |
$chk_member = sql_fetch("select mb_id from g4_login where lo_ip = '".$_SERVER[REMOTE_ADDR]."'"); |
06 |
if(!$chk_member[mb_id]) exit; |
07 |
$member = get_member($chk_member[mb_id]); |
08 |
} |
09 |
if($member[mb_level] < 3 || !$wr_id) exit; |
10 |
$h = sql_fetch("select wr_subject from test.g4_write_book where wr_id='$wr_id'"); |
11 |
$book_check = sql_fetch("select count(*) as cnt from $domain.$g4[point_table] where mb_id = '$member[mb_id]' and substring(po_datetime,1,10) = '$g4[time_ymd]' and po_rel_action = '읽기'"); |
12 |
if ($book_check[cnt]<3) insert_point($member[mb_id], "50", "$h[wr_subject] 읽기", $member[mb_id], $wr_id, '읽기'); |
13 |
if ($book_check[cnt]<3) star_insert_point($member[mb_id], "50", "$h[wr_subject] 읽기", $member[mb_id], $wr_id, '읽기'); |
댓글을 작성하려면 로그인이 필요합니다.
답변 2개
채택된 답변
+20 포인트
답변에 대한 댓글 2개
�
그누매너냐
11년 전
�
맞을꺼야
11년 전
제가 드린 말씀 요점은
sql_query(); 함수 내부에 보시면
function sql_query($sql, $error=TRUE)
{
// Blind SQL Injection 취약점 해결
$sql = trim($sql);
// union의 사용을 허락하지 않습니다.
$sql = preg_replace("#^select.*from.*union.*#i", "select 1", $sql);
// `information_schema` DB로의 접근을 허락하지 않습니다.
$sql = preg_replace("#^select.*from.*where.*`?information_schema`?.*#i", "select 1", $sql);
if ($error)
$result = @mysql_query($sql) or die("<p>$sql<p>" . mysql_errno() . " : " . mysql_error() . "<p>error file : $_SERVER[PHP_SELF]");
else
$result = @mysql_query($sql);
return $result;
}
위와 같이 되어 있습니다.
여기 보시면 @mysql_query()라는 부분이 있는데
여기에 DB커넥션 정보가 없으니 당연히 안된느겁니다.
아래와 같이 함수를 변경하셔서 하셔야 합니다.
function sql_query($sql, $error=TRUE, $dbconn)
{
중략
$result = @mysql_query($sql, $dbconn) or die("<p>$sql<p>" . mysql_errno() . " : " . mysql_error() . "<p>error file : $_SERVER[PHP_SELF]");
}
함수 바꾸시고
실행하는 항목에서
sql_query($sql,$connect_db2)
이런식으로 하셔야 합니다.
sql_query(); 함수 내부에 보시면
function sql_query($sql, $error=TRUE)
{
// Blind SQL Injection 취약점 해결
$sql = trim($sql);
// union의 사용을 허락하지 않습니다.
$sql = preg_replace("#^select.*from.*union.*#i", "select 1", $sql);
// `information_schema` DB로의 접근을 허락하지 않습니다.
$sql = preg_replace("#^select.*from.*where.*`?information_schema`?.*#i", "select 1", $sql);
if ($error)
$result = @mysql_query($sql) or die("<p>$sql<p>" . mysql_errno() . " : " . mysql_error() . "<p>error file : $_SERVER[PHP_SELF]");
else
$result = @mysql_query($sql);
return $result;
}
위와 같이 되어 있습니다.
여기 보시면 @mysql_query()라는 부분이 있는데
여기에 DB커넥션 정보가 없으니 당연히 안된느겁니다.
아래와 같이 함수를 변경하셔서 하셔야 합니다.
function sql_query($sql, $error=TRUE, $dbconn)
{
중략
$result = @mysql_query($sql, $dbconn) or die("<p>$sql<p>" . mysql_errno() . " : " . mysql_error() . "<p>error file : $_SERVER[PHP_SELF]");
}
함수 바꾸시고
실행하는 항목에서
sql_query($sql,$connect_db2)
이런식으로 하셔야 합니다.
댓글을 작성하려면 로그인이 필요합니다.
11년 전
lib/common.lib.php
파일에
insert_point()
함수에 DB컨넥팅 정보 넣어서 할 수 있도록 수정하셔야 합니다.
로그인 후 평가할 수 있습니다
답변에 대한 댓글 1개
�
그누매너냐
11년 전
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 커넥션 코드도 알려주세요
{
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 커넥션 코드도 알려주세요
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
$user_arr[] = $mysql_user = "root";
$password_arr[] = $mysql_password = "$1234";
$db_arr[] = $mysql_db = "yska";
$connect_db2 = sql_connect(${'mysql_host_'.$domain}, ${'mysql_user_'.$domain}, ${'mysql_password_'.$domain});
$select_db2 = sql_select_db(${'mysql_db_'.$domain}, $connect_db2);
이게 DB 커넥션 아닌가요?