계정 정보 출력하기 (게시물 갯수/회원 수/계정 사용량/DB 사용량 등등) > 그누4 팁자료실

그누4 팁자료실

그누보드4와 관련된 팁을 여러분들과 함께 공유하세요.
나누면 즐거움이 커집니다.

계정 정보 출력하기 (게시물 갯수/회원 수/계정 사용량/DB 사용량 등등) 정보

계정 정보 출력하기 (게시물 갯수/회원 수/계정 사용량/DB 사용량 등등)

첨부파일

space.inc.php (2.4K) 303회 다운로드 2005-07-21 11:10:14

본문

심심해서 한번 만들어 본 소스입니다.
스샷도 첨부해 놓았습니다. 보이시죠?? ^^
아래 소스를 복사하시거나 첨부한 파일을 다운로드하셔서 알맞게 수정하신 뒤에 사용하시기 바랍니다.
참고로 첨부된 소스에는 설명에 해당하는 주석이 하나도 없습니다. ^^;;
워낙 실력도 형편없고, 거의 짜집기 한거라서 ^^;;
여기에 사용된 거의 모든 소스가 N사이트에서 찾아서 바로바로 짜집기해서 만든 겁니다. ^^;;
아래는 허접한 소스입니다.

<?
// Byte를 KB, MB, GB로 변환하는 함수
function size($size) {
if(!$size) return "0 Byte";
if($size < 1024) {
return "$size Byte";
} elseif($size >= 1024 && $size < 1024 * 1024) {
return sprintf("%0.1f",$size / 1024)." KB";
} elseif($size >= 1024 * 1024 && $size < 1024 * 1024 * 1024) {
return sprintf("%0.1f",$size / 1024 / 1024)." MB";
} else {
return sprintf("%0.1f",$size / 1024 / 1024 / 1024)." GB";
}
}

// 총 게시물의 갯수, 총 코멘트의 갯수, 게시판의 갯수, 그리고 각 게시판의 테이블 명을 구함
$q_count = mysql_query("select * from g4_board");
$count_write = 0;
$count_comment = 0;
$count_board = 0;
$bo_tb = "0";
while($data=mysql_fetch_array($q_count)) {
$count_write += $data[bo_count_write];
$count_comment += $data[bo_count_comment];
$count_board++;
$bo_tb = $bo_tb."|".$data[bo_table];
}

// 각 게시판의 총 게시물 수, 총 코멘트 수, 새 게시물 수를 구함(현재 날짜와 등록된 날짜를 비교하여 같으면 새 게시물)
$bo_tb = explode("|", $bo_tb);
$i = 1;
$new_comment = 0;
$new_article = 0;
while($i<=$count_board) {
$q_new = mysql_query("select * from g4_write_".$bo_tb[$i]);
$m_total[$bo_tb[$i]] = 0;
while($dat=mysql_fetch_array($q_new)) {
$m_total[$bo_tb[$i]]++;
$m_article[$bo_tb[$i]] = 0;
if(substr($dat[wr_datetime],0,10)!=date("Y-m-d")) continue;
if($dat[wr_comment]<0) $new_comment++;
else {
$new_article++;
$m_article[$bo_tb[$i]]++;
}
}
$i++;
}
// 여기서 구한 각 게시판의 총 게시물과 새 게시물의 수는 각각 $m_total[테이블명], $m_article[테이블명] 으로 사용하시면 됩니다.

// 현재 접속한 회원 또는 비회원의 수를 구함(저는 스킨만들어 쓰기가 귀찮아서 이방법을;;;)
$q_connect = mysql_query("select * from g4_login");
$count_no_mb = 0;
$count_mb = 0;
while($data=mysql_fetch_array($q_connect)) {
if($data[mb_id] == "") $count_no_mb++;
elseif($data[mb_id] != "yhs6374") $count_mb++; // yhs6374 를 관리자 아이디로...
}

// 오늘 새로 누적된 포인트와 총 누적된 포인트를 구함
$q_point = mysql_query("select * from g4_point");
$new_point = 0;
$all_point = 0;
while($data=mysql_fetch_array($q_point)) {
if(substr($data[po_datetime],0,10)==date("Y-m-d")) $new_point += $data[po_point];
$all_point += $data[po_point];
}

// 새 회원 수와 총 회원 수를 구함
$m_count = mysql_query("select * from g4_member");
$new_member = 0;
$count_member = 0;
while($data=mysql_fetch_array($m_count)) {
if($data[mb_nick]=="[삭제됨]") continue;
if(substr($data[mb_datetime],0,10)==date("Y-m-d")) $new_member++;
$count_member++;
}

// 모든 게시판에 첨부된 파일의 갯수를 구함
$d_count = mysql_query("select * from g4_board_file");
$count_data = 0;
while(mysql_fetch_row($d_count)) {
$count_data++;
}

// 계정의 사용량을 구함
$account_space = `du -sb $g4[path]`;
$account_space = substr($account_space,0,strlen($account_space)-3);

// DATA 폴더의 용량을 구함
$data_space = `du -sb $g4[path]/data`;
$data_space = substr($data_space,0,strlen($data_space)-8);

// DB의 사용량을 구함
$result = mysql_query("SHOW TABLE STATUS");
$db_using = 0;
while($dbData=mysql_fetch_array($result)) {
$db_using += $dbData[Data_length]+$dbData[Index_length];
}
?>

=============================================================

소스가 끝났습니다.
아래는 적용된 예제입니다.

<table cellpadding=0 cellspacing=0 width=160>
<tr>
<td align=center>
- <b>계정 정보</b> -
</td>
</tr>
<tr>
<td style="font-size:8pt;">
File : <?=size($account_space)?><br>
Data : <?=size($data_space)?><br>
DB : <?=size($db_using)?><br>
&nbsp;
</td>
</tr>
<tr>
<td align=center>
- <b>게시판 정보</b> -
</td>
</tr>
<tr>
<td style="font-size:8pt;">
Board : <?=$count_board?><br>
Data File : <?=number_format($count_data)?><br>
New Article : <?=number_format($new_article)?><br>
Total Article : <?=number_format($count_write)?><br>
New Comment : <?=number_format($new_comment)?><br>
Total Comment : <?=number_format($count_comment)?><br>
New Member : <?=number_format($new_member)?><br>
Total Member : <?=number_format($count_member)?><br>
Connect : <?=number_format($count_no_mb+$count_mb)?><br>
&nbsp;(Member : <?=number_format($count_mb)?>)<br>
New Point : <?=number_format($new_point)?><br>
Total Point : <?=number_format($all_point)?><br>
&nbsp;
</td>
</tr>
</table>

=============================================================

각 게시판의 새 게시물 수와 총 게시물 수는

공지사항(<?=number_format($m_article[notice])?>/<?=number_format($m_total[notice]?>)

이런 형식으로 사용하시면 됩니다.
추천
15

댓글 28개

허접한 소스를 잘 써주신다니 감사합니다. ^^
7월 25일 11시 11분에 소스가 약간 변경되었습니다.
참고해주세요.
7월 25일 11시 11분에 소스가 약간 수정되었습니다. ^^
변경된 내용은 size 함수에 '$size > 1024' 와 '$size > 1024 * 1024' 에서 '>' 를 '>='로 바꾸었습니다.
감사합니다....

그런데..계정 정보에서 DB는 용량을 구하는것 같은데, file과 data는 0으로 나오네요.

그누 보드 최신 버전이고, 윈도우 APM5입니다.

혹시 윈도우에서 테스트해서 그런걸까요?
이 소스에서 사용한 것이 Linux 의 'du' 명령어입니다.
Windows 에서 사용하시면 당연히 0으로 나옵니다. ^^;;
제가 Windows 용 소스도 올리도록 하겠습니다.
잘 안되는군요...
위 파일 업로드 위치는 어디로 잡아도 상관없는가요?
G4 폴더내에도 위치해 봤고 별도의 폴더속에다 집어넣어 보기도 했는데...잘 안되네요...

- 계정 정보 - 
File :
Fatal error: Call to undefined function: size() in /www/zerosum/g4/html/space.php on line 9
그누보드4 페이지(예 : index.php)에 space.inc.php 파일을 include 나 include_once 를 이용하셔서 불러오신 뒤에 출력하는 소스를 집어넣으셔야 합니다. ^^
오류 메시지를 보니 space.inc.php 파일을 불러오지 않아서 size 라는 함수가 정의되지 않았다고 출력되는 오류 메시지네요. ^^
만약에 그냥 보통 페이지에 출력하실거라면 꼭 그누보드4의 common.php 파일을 include 나 include_once 로 불러오신 다음에 space.inc.php 파일을 include 나 include_once 하신 뒤에 출력하는 소스를 넣으시면 됩니다.
게시판의 head 나 tail 로 출력하시려면 head 파일이나 tail 파일을 만드셔서 그냥 space.inc.php 파일만 include 나 include_once 로 불러오신 뒤에 출력소스를 넣으시고 관리자 모드에서 게시판의 head 파일이나 tail 파일을 지정해주시면 됩니다.
그리고 보통 페이지에 출력하실거면 G4 폴더 내에 있는 common.php 를 include 나 include_once 를 이용하셔서 불러오신 뒤에 사용하셔야하는데, 불러오는 소스 위에 $g4_path 로 G4 폴더의 절대 경로를 지정해주시기 바랍니다.
아래는 보통 페이지에 출력하는 예제입니다. 참고하세요. ^^

예제) 출력하려는 파일과 space.inc.php 파일이 G4 폴더 내에 있을 때
<?
$g4_path = ".";
include_once($g4_path."/common.php");
include_once("space.inc.php");
?>
~~~~출력하는 소스~~~~
위의 예제에 문제가 있네용...
<?
$g4_path = ".";
include_once($g4_path."/common.php");
include_once("space.inc.php");
?>
=============================== 이것을
<?
$g4_path = ".";
include_once($g4_path."/common.php");
include_once($g4[path]."/space.inc.php");
?>
이렇게 바꿔주세요.... ^^;; common.php 파일을 불러온 뒤에는 $g4_path 가 안 먹히는 것 같더군요...
게시판별 [오늘/전체 게시물] [오늘/전체 코멘트] 구하기
오랫동안 검색을 해봤는데 원하는 답을 못얻었습니다.
트랙백주소에 있는 소스를 돌려봤지만 전체 계정만 나오지 게시판별 수는 구할수가 없었습니다.

구현하고싶은게 바로 그림에 있는겁니다. 링크에 샘플사이트라고 검색했더니 나오더라구요.
그누를 이용한거 같은데.…
소스 24줄
if($dat[wr_comment]<0) $new_comment++; 를 아래와 같이 수정해야
if($dat[wr_comment]>0) $new_comment++;

제대로 신규코멘트수가 나옵니다.
전체 0 |RSS
그누4 팁자료실 내용 검색
  • 개별 목록 구성 번호 제목 작성자 작성일 추천 조회
  • 게시물이 없습니다.

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT