CMS/프레임워크 | Rhymix 1.9 |
---|---|
개발 언어 | PHP 7.0 |
이번에 라이믹스쪽에 건의한 내용 (https://github.com/rhymix/rhymix/issues/1124) 요게 바로 해결되었는데,
좋습니다. 좋아요.
근데 제가 https://xetown.com/point_contents/22521 요 포인트차감 경고 애드온을 사용중입니다.
저 라이믹스 공지 포인트차감 제외를 클릭하면 실제로 공지에서 포인트가 차감되지 않습니다.
그런데 저 애드온은 공지를 클릭해도 차감경고 문구가 뜨게 되있네요...
두서없이 말해서 간단하게 설명해보자면,
라이믹스 포인트 차감 공지제외 사용>그런데 공지 클릭하면 알럿창 뜸>근데 실제로는 당연히 포인트차감 안됨
저는 이 애드온에서 공지만 알럿창이 나오지 않게 수정하고 싶습니다.
PHP에 거의 문외한 수준이라 도움좀 부탁드리겠습니다.
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);
}
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);
}
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.'>';
}
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.'>';
}
공지만 제외한다 라는 실행문?을 넣고 싶습니다.
댓글 2
아랫줄에 이렇게만 해주면 될 것 같기도 합니다
if ($oDocument->isNotice()) {
return $matches[0];
}
막힌점만 딱딱 해결해주시네요.
정말 감사드립니다 ㅠ