묻고답하기

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

    /**
     * @file sejin7940_write_limit.addon.php
     * @author sejin7940 ( http://sejin7940.co.kr)
  * @source author 난다날아 (sinsy200@gmail.com)
     * @brief 하루에 작성할 수 있는 글/댓글을 제한합니다.
     *
     **/

 // 로그인 정보 가져오기
 $logged_info = Context::get('logged_info');

 // 관리자면 통과!!
 if ($logged_info->is_admin == 'Y') return;

 // 오늘 작성글 개수를 가져온다.
 // 비회원은 ip를 기준으로...

 $args->today = date("Ymd");
 if (!logged_info) $args->ipaddress =  $_SERVER['REMOTE_ADDR'];
 else    $args->member_srl = $logged_info->member_srl;

 if($addon_info->mid_list) {
     $oModuleModel = &getModel('module');
  $limit_module_srl_array = $oModuleModel->getModuleSrlByMid($addon_info->mid_list);
  $limit_module_srls=implode(',',$limit_module_srl_array);
 }
 if($addon_info->mid_together=="Y") {  // 선택한 게시판 통합 적용
  if(count($addon_info->mid_list)) $args->limit_module_srl = $limit_module_srls;  // 선택한 게시판
  else $args->limit_module_srl="";  // 전체
 }
 else if($addon_info->mid_list) {  // 선택한 게시판 별도 각각 적용
  if(strstr(','.$limit_module_srls.',',','.$this->module_info->module_srl.',')) {
   $args->limit_module_srl = $this->module_info->module_srl;
  }
  else return;
 }
 else $args->limit_module_srl="";  // 전체


//echo $addon_info->mid_list[0]."<br>";   // 모듈목록
//echo $this->module_info->mid;   // 현재위치의 module_srl 값
    Context::loadLang(_XE_PATH_.'addons/sejin7940_write_limit/lang');
   
 // 글 작성시
 if($called_position == 'before_module_init'+ ' && $this->act == 'procBoardInsertDocument' && !Context::get('document_srl')) {  // sejin7940 수정 (수정시 작동 안 하도록 하기 위해서)
  // 제한이 걸려있지 않으면 통과!
  if (!$addon_info->document_limit) return;
  


  $output = executeQuery('addons.sejin7940_write_limit.document_count', $args);

  if (!$output->toBool()) {
            $error = $output->getMessage();
   // xml_rpc return
   header("Content-Type: text/xml; charset=UTF-8");
   header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
   header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
   header("Cache-Control: no-store, no-cache, must-revalidate");
   header("Cache-Control: post-check=0, pre-check=0", false);
   header("Pragma: no-cache");
   print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<response>\r\n<error>-1</error>\r\n<message>$error</message>\r\n</response>");

   Context::close();
   exit();
  }

  // 설정된 개수 이상의 작성이면 중단!

  if ($output->data->count >= $addon_info->document_limit  ) {
   // xml_rpc return
   header("Content-Type: text/xml; charset=UTF-8");
   header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
   header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
   header("Cache-Control: no-store, no-cache, must-revalidate");
   header("Cache-Control: post-check=0, pre-check=0", false);
   header("Pragma: no-cache");
   printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<response>\r\n<error>-1</error>\r\n<message>".Context::getLang('msg_limit_document')."</message>\r\n</response>", $addon_info->document_limit);

   Context::close();
   exit();
  }

    // 글 작성 화면
    }else if($called_position == 'after_module_proc' && $this->act == 'dispBoardWrite' && !Context::get('document_srl')) {  // sejin7940 수정 (수정시 작동 안 하도록 하기 위해서)
        // 제한이 걸려있지 않으면 통과!
  if (!$addon_info->document_limit) return;

        // 게시판에서 메시지가 나가면 중단
        if ($this->getTemplateFile() == 'message.html') return;
       
  $db_output = executeQuery('addons.sejin7940_write_limit.document_count'+ ', $args);

  if (!$db_output->toBool()) {
   $this->errer = "SQL Error";
   return;
  }

  // 설정된 개수 이상의 작성이면 중단!
  if ($db_output->data->count >= $addon_info->document_limit) {
   $output = new Object(-1, sprintf(Context::getLang('msg_limit_document'), $addon_info->document_limit));
   return;
  }
 // 댓글 작성 때
    }else if($called_position == 'before_module_init' && $this->act == 'procBoardInsertComment') {

  // 제한이 걸려있지 않으면 통과!
  if (!$addon_info->comment_limit) return;
  
  // 오늘 작성 댓글 개수를 가져온다.
  $output = executeQuery('addons.sejin7940_write_limit.comment_count', $args);
  if (!$output->toBool()) {
            $error = $output->getMessage();
   // xml_rpc return
   header("Content-Type: text/xml; charset=UTF-8");
   header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
   header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
   header("Cache-Control: no-store, no-cache, must-revalidate");
   header("Cache-Control: post-check=0, pre-check=0", false);
   header("Pragma: no-cache");
   print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<response>\r\n<error>-1</error>\r\n<message>$error</message>\r\n</response>");

   Context::close();
   exit();
  }

  // 설정된 개수 이상의 작성이면 중단!
  if ($output->data->count >= $addon_info->comment_limit) {
   // xml_rpc return
   header("Content-Type: text/xml; charset=UTF-8");
   header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
   header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
   header("Cache-Control: no-store, no-cache, must-revalidate");
   header("Cache-Control: post-check=0, pre-check=0", false);
   header("Pragma: no-cache");
   printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<response>\r\n<error>-1</error>\r\n<message>".Context::getLang('msg_limit_comment')."</message>\r\n</response>", $addon_info->comment_limit);

   Context::close();
   exit();
  }

    }
?>

 

위는 댓글제한 애드온 php파일입니다.

만약 댓글 제한 갯수가 20개라면 19번째 댓글을 등록할때 '댓글 작성 가능 횟수가 1회 남았습니다' 라는 알림창을 보여주고 싶은데...

아직 초보수준이라 수정이 쉽지 않네요 ㅠㅠ

고수분들의 도움 부탁드립니다~

글쓴이 제목 최종 글
XE 공지 글 쓰기,삭제 운영방식 변경 공지 [16] 2019.03.05 by 남기남
김동하123 () 로보이는 설치 위젯 [2] file 2011.10.24 by 김동하123
김동하123 쉬운설치 안보이고 설치한 위젯도 안보입니다. [7] 2011.10.24 by 배워서남준다
니호호호호홍 xe게시판 ... 용량 늘리는거요..ㅠ_ㅠ [3] 2011.10.24 by 류군
캉디드 이것좀 해결해 주세요... file  
hong`s 쉬운설치 리스트 언제 나오나요. [1] 2011.10.24 by 송동우
은빛하늘264 메뉴를 만들었는데...(답변부탁드립니다!!) [2] file 2011.10.24 by 배워서남준다
준돌이 레이아웃 사소한 오류 질문 이요! [2] file 2011.10.24 by 배워서남준다
나는새 회원가입폼을 레이아웃 안에 넣고싶습니다  
모르겠어요 생일달력 재질문.. [1] 2011.10.24 by 배워서남준다
홍길동친구 로그인 하여 뜨는 레이아 팝업을 통일 시키고 싶어요~ (이미지) [1] file 2011.10.24 by 배워서남준다
성시훈 아주 사소한 질문 최근글 글자수 늘리기 [1] 2011.10.24 by 배워서남준다
저먼하늘아래 위젯의 이미지 소스 [1] 2011.10.24 by 배워서남준다
엄한소년 모바일환경에서 쪽지 보기 및 답하기.  
모르겠어요 회원가입 시, 생일달력이 가려져서 안보여요 [1] file 2011.10.24 by 송동우
모르겠어요 xe기본게시판 글쓰기버튼 [1] 2011.10.24 by 송동우
윤제한 제로보드4의 방문자 수를 가져올 수 없나요? [1] 2011.10.24 by 쿵푸팬더
김동하123 게시판을 폼메일처럼 쓰기 [1] 2011.10.24 by 송동우
김동하123 비회원글쓰기에서 닉네임 넣지 않기 [1] 2011.10.24 by 송동우
툴툴스 현재 사용중인 출석부 모듈에서요... [1] 2011.10.24 by 송동우
홍길동친구 포인트, 다운로드 관련하여 몇가지 질문들입니다. [6] 2014.11.14 by 송동우
김동하123 아래로 목록 따라나오지 않게 하기 [1] 2011.10.24 by 송동우
Sunt XE 기본 카운터에 특정 모듈만 출력되기 [1] 2011.10.24 by 송동우
도라란 이 소스가 맞는지 살펴봐 주시면 감사하겠습니다. [1] 2011.10.24 by 송동우
도라란 특정위치의 DB에 내용이 있을 경우, 게시판 글 본문에 지정내용 보여주기 [1] file 2011.10.24 by 송동우
제로보드굿굿 동우님.. 봐주세요 ㅠㅠ [2] 2011.10.24 by 굿총
화재내니학교 쉬운설치 [1] 2011.10.24 by 카이네드
BITTER 캐시파일 재생성  
송지욱745 모든 회원정보와 관리자 아이디까지 없어졌습니다. ㅠ (답변이 없어서 다시 올려요..ㅠㅠ)  
국가대표1 게시판 게시글 복원 문의좀 제발 플리즈  
김동하123 위젯 쉬운 설치 이후(답변프리즈)