티스토리 뷰

반응형

/bbs/link.php 

로 만들어서 사용하는 법

 

다운로드 포인트 차감을 이용해서 만든다.

 

 

<?php
include_once('./_common.php');

$html_title = '링크 &gt; '.conv_subject($write['wr_subject'], 255);

if (!($bo_table && $wr_id && $no))
    alert_close('값이 제대로 넘어오지 않았습니다.');

// SQL Injection 예방
$row = sql_fetch(" select count(*) as cnt from {$g5['write_prefix']}{$bo_table} ", FALSE);
if (!$row['cnt'])
    alert_close('존재하는 게시판이 아닙니다.');

if (!$write['wr_link'.$no])
    alert_close('링크가 없습니다.');

@include_once($board_skin_path.'/link.head.skin.php');

$ss_name = 'ss_link_'.$bo_table.'_'.$wr_id.'_'.$no;
if (empty($_SESSION[$ss_name]))
{
    $sql = " update {$g5['write_prefix']}{$bo_table} set wr_link{$no}_hit = wr_link{$no}_hit + 1 where wr_id = '{$wr_id}' ";
    sql_query($sql);

    set_session($ss_name, true);

// 새글 업데이트
$as_link = (int)$write['wr_link1_hit'] + (int)$write['wr_link2_hit'] + 1;
sql_query(" update {$g5['board_new_table']} set as_link = '{$as_link}' where bo_table = '{$bo_table}' and wr_id = '{$wr_id}' ", false);
}

@include_once($board_skin_path.'/link.tail.skin.php');

goto_url(set_http($write['wr_link'.$no]));
?>

 

그리고 나서 스킨에서 적당하게

 

link.tail.skin.php 화일을 만들어서

 

if (!defined('_GNUBOARD_')) exit; //개별 페이지 접근 불가
// 자신의 글이라면 통과
// 관리자인 경우 통과
//if (($write['mb_id'] && $write['mb_id'] == $member['mb_id']) || $is_admin == 'super')
//    ;
// else
 if ($board['bo_download_level'] > 1) // 회원이상 다운로드가 가능하다면
{
$timestamp = "-".$board['bo_1']." days";//" minutes";// 날짜 몇일 지나야 초기화인지.
$sql_term = "and po_datetime > '".date("Y-m-d H:i:s", strtotime($timestamp))."'"; // 기간(일수,today,yesterday,month,prev)
$row = sql_fetch(" select count(*) as cnt from {$g5['point_table']} where mb_id = '{$member['mb_id']}' and po_rel_table = '$bo_table' and po_rel_id = '$wr_id' and po_rel_action = '링크 다운로드' ".$sql_term);
//print_r($row);
$download_period = ($row['cnt']) ? true : false;//다운받은지 지정된 기간 이내인 경우라면
//alert($download_period);
//$download_period = false;

if(!$download_period || 1==true){//기간없이 누를때마다 매번 차감되게끔
    // 다운로드 포인트가 음수이고 회원의 포인트가 0 이거나 작다면
    if ($member['mb_point'] + $board['bo_download_point']<0)
        alert('보유하신 포인트('.number_format($member['mb_point']).')가 없거나 모자라서 링크('.number_format($board['bo_download_point']).')가 불가합니다.\n\n포인트를 적립하신 후 다시 다운로드 해 주십시오.');
 
    // 게시물당 한번 차감하도록 수정
    //insert_point($member['mb_id'], $board['bo_download_point'], "{$board['bo_subject']} $wr_id 링크 다운로드", $bo_table, $wr_id, "링크 다운로드"); 
    // 게시물당 계속 차감 하도록 수정(차감조건을 기간으로 설정하기 때문에);
    insert_point($member['mb_id'], $board['bo_download_point'], "{$board['bo_subject']} $wr_id 링크 다운로드 _".G5_TIME_YMDHIS, $bo_table, $wr_id, "링크 다운로드","0","1"); 
}
}
?>

반응형
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함