로그인

검색


DS918+에서 테스트 했습니다.

필요 패키지: 웹스테이션(아파치2.2, php5.6), 텍스트 편집기

위 패키지 설치 및 설정은 인터넷 검색하셔서 진행하시면 됩니다.

 

1.  작업 스캐줄러 등록.

`제어판 - 작업 스캐줄러`

생성 - 예약된 작업 - 사용자 정의 스크립트
스케줄 탭 - 시간 - 첫 실행 시간: 00:20 - 주기: 매시간 - 마지막 실행 시간: 23:20
(위 스케줄은 본인에 맞게 설정하세요.)
작업설정 탭 - 아래 내용 복/붙

cut -f1,3 -d: /etc/passwd > /var/services/tmp/ulist.txt
psql -U postgres -d video_metadata -t -A -c "SELECT id,path,filesize,duration FROM video_file;" > /var/services/tmp/vfile.txt
psql -U postgres -d video_metadata -t -A -c "SELECT id,uid,video_file_id,position,create_date,modify_date FROM watch_status ORDER BY modify_date DESC;" > /var/services/tmp/watch.txt

 

위 내용도 알아서 본인 환경에 맞게 작업 스케줄러에 등록하시면 됩니다.
제 경우엔 ulist.txt는 재부팅(시작) 할때만 한번 가져옵니다.

사용자를 자주 추가하는게 아니라서요. 본인이 자주 추가한다면 자주 업데이트 해주셔야 겟죠.

(생성 - 트리거된 작업 - 사용자 정의 스크립트 - 이벤트: 부트업)
vfile.txt도 8시간마다...
watch.txt는 1시간마다...

 

 

2. 폴더생성.

DSM - 파일 스테이션 - web - 폴더생성: status

 

3. php파일 생성.

파일편집기 - 파일 - 새로 만들기 - 아래 내용 복/붙 - 파일 - 저장 - 폴더: web/status - 파일이름: status.php - 인코딩: unicode(utf-8) - 저장.

 

<?php
$ipPass = array($_SERVER["SERVER_ADDR"],"접속허용 아이피(집)","접속허용 아이피(회사?)");
//접속허용 아이피를 필요한 만큼 추가하세요.
if(!in_array($_SERVER['REMOTE_ADDR'], $ipPass)) exit;

date_default_timezone_set('Asia/Seoul');

function filesize_formatted($size)
{
    $units = array( 'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
    $power = $size > 0 ? floor(log($size, 1024)) : 0;
    return number_format($size / pow(1024, $power), 2, '.', ',') . ' ' . $units[$power];
}

$a = array();
//사용자정보 가져오기
//안봐도 되는 계정들 등록. 관리자가 사용중인 본인 계정도 넣으시면 되구요.
$idBan  = array("guest","admin");
$user_list = file_get_contents('/var/services/tmp/ulist.txt');
$n = explode("\n",$user_list);
foreach($n as $l){
list($id,$uno) = explode(":",$l);
//사용자 계정이 1000명이 넘으면...뒤에 2000을 늘려주세요.
if($uno<1000 || $uno>2000) continue;
if(in_array($id,$idBan)) continue;
if($id) $a['u'][$uno]=$id;//mb_strimwidth($id,0,3,'***','utf-8');
}

$video_file = file_get_contents('/var/services/tmp/vfile.txt');
$n = explode("\n",$video_file);
foreach($n as $l){
list($id,$path,$filesize,$duration) = explode("|",$l);
if($id) $a['v'][$id]=array(array_pop(explode("/",$path)),$duration,filesize_formatted($filesize));
}

$watch_status = file_get_contents('/var/services/tmp/watch.txt');
$n = explode("\n",$watch_status);
foreach($n as $l){
list($id,$uid,$video_file_id,$position,$create_date,$modify_date) = explode("|",$l);
if($id && $a['u'][$uid]) $a['w'][$id]=array($a['u'][$uid],$a['v'][$video_file_id][0],array_shift(explode(".",$modify_date)),array_shift(explode(".",$create_date)),$position,$a['v'][$video_file_id][1],$a['v'][$video_file_id][2]);
}
?>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>비디오스테이션 사용목록</title>
</head>
<body style="font-size:9pt;">
<table>
<thead style="background:black;color:white;">
<tr>
<th>아이디</th>
<th>파일이름</th>
<th>파일크기</th>
<th>최근재생</th>
<th>처음재생</th>
<th>재생위치</th>
<th>재생시간</th>
</tr>
</thead>
<tbody style="background:gray;color:white;">
<?php
foreach($a['w'] as $id => $v){
if($v[3]<date("Y-m-d H:i:s",strtotime("-7 day"))) continue;
echo' <tr><td>'.(strlen($v[0])>6?(strlen($v[0])>9?substr($v[0],0,-6):substr($v[0],0,-3)):substr($v[0],0,-2)).'*****</td><td>'.$v[1].'</td><td>'.$v[6].'</td><td>'.$v[2].'</td><td>'.$v[3].'</td><td>'.gmdate('H:i:s',$v[4]).'</td><td>'.gmdate('H:i:s',$v[5]).'</td></tr>'.PHP_EOL;
}
?>
</tbody>
</table>
</body>
</html>

 

 

status.zip

 

4. 확인하기

주소줄에 `http://나스 사설IP or 공인IP/status/status.php` 실행.

아래 이미지 처럼 나오면 성공하신 겁니다.


  • ?
    건실한중년 2023.11.20 04:58
    dsm 7.2.1 입니다.
    아파치2.4 , php8.2
    웹스테이션 사용입니다.
    스케쥴러 실행시 아래와 같이 log 출력되는데, 무엇이 문제 일까용?

    psql: FATAL: Peer authentication failed for user "postgres"

리눅스

유용한 정보 및 자료

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
204 Server 우분투 nginx rewrite 보석 2011.11.03 235869
203 XE XE 특정 회원이 보낸 쪽지만 삭제하는 쿼리 보석 2013.08.23 121599
202 Server 우분투 mysql DB 파일 위치 변경 방법 패키지로 설치 했을 경우 보석 2013.08.26 57380
201 Server [리눅스] 새 계정 만들기/지우기, 사용자 아이디 추가/삭제; Create Account 1 보석 2011.08.31 39168
200 Server 리눅스용 무료 웹하드 <shade webhard> 설치하기 file 보석 2011.10.17 36136
199 Server [우분투] screen 명령어 보석 2013.02.04 33016
198 Server 우분투 리눅스에서 APM 설치하기 (웹서버 설정) 보석 2011.07.04 32846
197 XE XE 관리그룹만 글쓰기버튼 보이게 하기 보석 2012.11.02 31552
196 Server Startssl.com 무료 ssl 인증서 서버 설정 보석 2012.08.17 31199
195 XE 레벨아이콘과 그룹아이콘 동시에 출력하기 보석 2012.09.05 31098
194 XE XE 닉네임 글자수 제한 보석 2012.09.19 30815
193 XE XE 특정게시판만 코드 실행문 2 보석 2013.03.07 30193
192 XE XE 추천시 추천하는 사람도 포인트 받기 보석 2013.03.12 29681
191 Server 우분투 가상호스트 설정 보석 2011.05.15 28853
190 Server 우분투 Memcached 설치는 이렇게 보석 2011.10.19 28786
189 XE XE 1.5.X 용 nginx rewrite rule 2 보석 2013.02.22 28373
188 Server Nginx 가상호스트 설정 1 보석 2011.10.31 27860
187 XE XE 1.7.X 용 nginx rewrite rule 보석 2013.02.22 27280
186 XE XE 추천수가 일정수준을 넘으면 게시판 이동시키기 6 보석 2013.03.07 27076
185 Server 링크하드 리눅스 설치 성공담 - 웹하드 WebHard Linux Install 보석 2011.10.17 27005
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 Next
/ 11