로그인

검색


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 Pydio ajaxplorer 3.0 설정 및 한글 파일 다운로드 및 압축문제 해결 file 보석 2011.10.16 16443
203 Pydio ajaXplorer 한글파일 업로드시 411 에러 해결법 보석 2014.02.09 7510
202 Server CSS Background 속성 보석 2011.10.03 9759
201 Server DB 백업 스크립트 (우분투 기준) 보석 2011.05.15 12307
200 Server Install Nginx, PHP5, PHP-FPM and MySQL on Ubuntu 11.04 보석 2011.10.31 25494
199 Server Installing Nginx With PHP5 (And PHP-FPM) And MySQL Support On Ubuntu 11.10 1 보석 2011.11.01 25692
198 KimsQ kimsq v1.1.0 기준 nginx rewrite rule 보석 2013.08.23 12777
197 Server kimsq 파일 다운로드시 포인트 차감 설정 보석 2011.05.18 11305
196 기타 MySQL 기본쿼리 : DELETE 문 보석 2013.03.14 15561
195 Server mysql 튜닝 방법 보석 2013.08.25 17577
194 Server Nginx 가상호스트 설정 1 보석 2011.10.31 27860
193 Server nginx 무한 F5 막기 보석 2014.04.08 6527
192 Server Nginx 버전 정보 숨기기 보석 2013.08.23 16925
191 Server nginx 첨부파일 용량 설정 보석 2012.04.02 18747
190 Server Proftp 버전 및 프로그램명 숨기기 보석 2013.08.23 18299
189 Pydio Pydio AjaXplorer Mcrypt Enabled, Security Brench, Server charset encoding, php output disabled 오류해결 보석 2016.05.18 106
188 Pydio Pydio AjaXplorer 버전별 다운로드 보석 2016.05.18 88
187 Pydio Pydio AjaXplorer 업로드후 Impossible write into the AJXP_DATA_PATH folder ajaxplorer 나올때 보석 2016.05.18 181
186 KimsQ RBSHOP 킴스큐쇼핑몰 가입시 포인트 적립금으로 바꾸기 보석 2013.08.23 15071
185 Server Rewrite 묘듈 활성화 Apache rewrite 활성화하기 보석 2013.08.23 17584
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 Next
/ 11