Q&A

포인트 차감 경고 애드온 사용 중이신 분 계신가요?

2025.02.20 10:25
73
0
0
CMS/프레임워크 Rhymix 2.1
개발 언어 PHP 7.4

포인트 차감 경고 애드온 ( https://xetown.com/download/22521 ) 이 라이믹스 최신 버젼에서 "파일 다운로드" 시 아무런 경고창이 뜨질 않고 바로 다운로드가 되어 버리는데요. 그동안 라이믹스 업데이트로 작동이 되질 않는 부분인지, 쳇 gpt 조언도 해결책이 되질 않는데요. 혹시 정상 사용중이신분 계신가요?

 

msg_minus_point.lib.php

<?php

function msgMinusPointDocumentRead($matches)
{
$document_srl = $matches[4];
if(!$document_srl || preg_match('/act\=/i', $matches[0]) || $_SESSION['readed_document'][$document_srl])
{
return $matches[0];
}

unset($GLOBALS['XE_DOCUMENT_LIST'][$document_srl]);

if(!$GLOBALS['_documentModel']) $GLOBALS['_documentModel'] = getModel('document');
$oDocumentModel = $GLOBALS['_documentModel'];
$oDocument = $oDocumentModel->getDocument($document_srl);

if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
{
return $matches[0];
}

$logged_info = Context::get('logged_info');
if($oDocument->get('member_srl') == $logged_info->member_srl)
{
return $matches[0];
}

$module_srl = $oDocument->get('module_srl');
if(!$GLOBALS['_point_module_config'][$module_srl])
{
if(!$GLOBALS['_moduleModel']) $GLOBALS['_moduleModel'] = getModel('module');
$oModuleModel = $GLOBALS['_moduleModel'];
$GLOBALS['_point_module_config'][$module_srl] = $oModuleModel->getModulePartConfig('point', $module_srl);
}
$module_config = $GLOBALS['_point_module_config'][$module_srl];

$read_point = $module_config['read_document'];
if(strlen($read_point) == 0 && !is_int($read_point)) $read_point = $GLOBALS['_point_config']->read_document;

if(!$read_point || $read_point >= 0)
{
return $matches[0];
}

if(Context::get('is_logged'))
{
$args = new stdClass;
$args->member_srl = $logged_info->member_srl;
$args->document_srl = $document_srl;
$tmp_output = executeQuery('document.getDocumentReadedLogInfo', $args);

if($tmp_output->data->count)
{
return $matches[0];
}

$pintmsg = sprintf('onclick="if(!confirm(\'%s\')) return false;"', str_replace('[P]', number_format($read_point), $GLOBALS['msg_point_dopen']));
}
else
{
$pintmsg = sprintf('onclick="alert(\'%s\'); return false;"', $GLOBALS['msg_point_dopen_login']);
}

$oltext = str_replace('>', ' ', $matches[0]);

return $oltext.$pintmsg.'>';
}

function msgMinusPointDownloadFile($matches)
{
$file_srl = $matches[4];
if(!$file_srl)
{
return $matches[0];
}

$args = new stdClass;
$args->file_srl = $file_srl;
$tmp_output = executeQuery('file.getFile', $args);
$file_info = $tmp_output->data;

$logged_info = Context::get('logged_info');
if($file_info->member_srl == $logged_info->member_srl)
{
return $matches[0];
}

$module_srl = $file_info->module_srl;
if(!$GLOBALS['_point_module_config'][$module_srl])
{
if(!$GLOBALS['_moduleModel']) $GLOBALS['_moduleModel'] = getModel('module');
$oModuleModel = $GLOBALS['_moduleModel'];
$GLOBALS['_point_module_config'][$module_srl] = $oModuleModel->getModulePartConfig('point', $module_srl);
}
$module_config = $GLOBALS['_point_module_config'][$module_srl];

$download_point = $module_config['download_file'];
if(strlen($download_point) == 0 && !is_int($download_point)) $download_point = $GLOBALS['_point_config']->download_file;

if(!$download_point || $download_point >= 0)
{
return $matches[0];
}

if(Context::get('is_logged'))
{
$pintmsg = sprintf('onclick="if(!confirm(\'%s\')) return false;"', str_replace('[P]', number_format($download_point), $GLOBALS['msg_point_download']));
}
else
{
$pintmsg = sprintf('onclick="alert(\'%s\'); return false;"', $GLOBALS['msg_point_download_login']);
}

$oltext = str_replace('>', ' ', $matches[0]);

return $oltext.$pintmsg.'>';
}

 

 

msg_minus_point.addon.php

<?php
    if(!defined("__XE__")) exit;

    /**
    * @file msg_minus_point.addon.php
    * @author CONORY (http://www.conory.com)
    * @brief 포인트차감 경고 애드온
    **/

if($called_position != 'before_display_content' || Context::getResponseMethod() != 'HTML' || Context::get('module') == 'admin') return;

//아이템 샵 자유 이용권
if(Context::get('is_logged') && is_dir('./modules/itemshop'))
{
$oItemshopModel = getModel('itemshop');
$oPossess = $oItemshopModel->getPossessInfo();
if($oPossess)
{
foreach($oPossess as $possess)
{
if($possess->item_condition == 'apply' && $possess->sale_item == 'download_free')
{
$download_free = true;
}
elseif($possess->item_condition == 'apply' && $possess->sale_item == 'read_free')
{
$read_free = true;
}
}
}
}

require_once(_XE_PATH_ . 'addons/msg_minus_point/msg_minus_point.lib.php');

$oModuleModel = getModel('module');
$GLOBALS['_point_config'] = $oModuleModel->getModuleConfig('point');

//게시글 조회
if(!$read_free)
{
$GLOBALS['msg_point_dopen'] = $addon_info->msg_point_dopen?$addon_info->msg_point_dopen:'게시물 열람시 [P]P가 차감됩니다. 그래도 열람하시겠습니까?\\n(이번만 차감되며, 다음번에는 차감되지않습니다.)';
$GLOBALS['msg_point_dopen_login'] = $addon_info->msg_point_dopen_login?$addon_info->msg_point_dopen_login:'게시물 열람은 포인트 차감제입니다. 먼저 로그인부터 해주세요.';

$output = preg_replace_callback('!\<a([^\>]*)href\=\"([^\>]*)(document_srl\=|/)([0-9]+)([^\>]*)\"([^\>]*)\>!is', 'msgMinusPointDocumentRead', $output);
}

//다운로드
if(!$download_free)
{
$GLOBALS['msg_point_download'] = $addon_info->msg_point_download?$addon_info->msg_point_download:'파일 다운로드시 [P]P가 차감됩니다. 그래도 다운로드하시겠습니까?\\n(다운로드할때마다 계속 차감됩니다.)';
$GLOBALS['msg_point_download_login'] = $addon_info->msg_point_download_login?$addon_info->msg_point_download_login:'파일 다운로드는 포인트 차감제입니다. 먼저 로그인부터 해주세요.';

$output = preg_replace_callback('!\<a([^\>]*)href\=\"([^\>]*)act\=procFileDownload([^\>]*)file_srl\=([0-9]+)([^\>]*)\"([^\>]*)\>!is', 'msgMinusPointDownloadFile', $output);
}

 

마트몬 Lv. 8

댓글 0