오늘은 대한입니다.
sun's longitude:299 52 30.93 
· 자유게시판 · 묻고답하기 · 알파문서 · RPMS list
· 사용자문서 · 팁/FAQ모음 · 리눅스Links · 자료실
· 서버정보 · 운영자 · Books/FAQ · FreeBSD
/board/delete.php:소스보기  
알파문서
자주 잊어먹거나, 메모해 둘 필요성이 있는 팁이나 문서, 기타 등등
[*** 쓰기 금지단어 패턴 ***]
글 본문 중간에 업로드할 이미지를 추가하는 방법 : @@이미지이름@@
ex) @@foo.gif@@
 ★ 글 지우기 항목입니다. 한번 더 생각하시고 결정하십시오.!!!
제목 18 : [PHP] class of OGG
 이름  산이 [홈]http://linuxchannel.net
<?php

// THIS IS BETA. DO NOT USE UNLESS YOU ENJOY THE RISK OF VERY BAD THINGS
// HAPPENING TO YOUR DATA. That said, it doesn't write anything so it
// should be harmless. This has been tested on a few ogg files I've
// created for testing but that is it.

// Uncomment the following define if you want tons of debgging info.
// Tip: make sure you use a <PRE> block so the print_r's are readable.
// define('OGG_SHOW_DEBUG', true);

class ogg {
/*
* ogg - A Class for reading Ogg comment tags
*
* By Sandy McArthur, Jr. <Leknor@Leknor.com>
*
* Copyright 2001 (c) All Rights Reserved, All Responsibility Yours
*
* This code is released under the GNU LGPL Go read it over here:
* http://www.gnu.org/copyleft/lesser.html
*
* I do make one optional request, I would like an account on or a
* copy of where this code is used. If that is not possible then
* an email would be cool.
*
* Warning: I really hope this doesn't mess up your Ogg files but you
* are on your own if bad things happen.
*
* To use this code first create a new instance on a file. Then loop
* though the $ogg->fields array. Inside that loop, loop again. The
* ogg comment format allows mome then one field with the same name
* so it is possible for the ARTIST fields to appear twice if a work
* has two performers.
*
* eg:
* require_once('class.ogg.php');
* $ogg = new ogg('/path/to/filename.ogg');
* echo '<UL>';
* foreach ($ogg->fields AS $name => $val) {
* echo "<LI>$name:<OL>";
* foreach ($val AS $contents) {
* echo '<LI>', $contents;
* }
* echo '</OL>';
* }
* echo '</UL>';
*
* This site was useful to me:
* http://www.xiph.org/ogg/vorbis/docs.html
*
* Change Log:
* 0.10: Clean up for release.
* 0.01: Got off my ass and wrote something until it works enough.
*
* Thanks To:
*
* TODO:
* Collect nifty info like bitrate, etc...
* Maybe implement ogg comment writer. We'll see I don't like using php
* to manipulate large amounts of data.
*
* The most recent version is available at:
* http://Leknor.com/code/
*
*/

var $_version = 0.10; // Version of the ogg class (float, not major/minor)

var $file = false; // ogg file name (you should never modify this)

var $fields = array(); // comments fields, this is a two dimentional array.
var $_rawfields = array(); // The comments fields read and split but not orgainzed.

var $error = false; // Check here for an error message
var $debug = false; // print debugging info?
var $debugbeg = '';
var $debugend = '';

/*
* ogg constructor - creates a new ogg object
*
* $file - the path to the ogg file. When in doubt use a full path.
*/
function ogg($file) {
if (defined('OGG_SHOW_DEBUG')) $this->debug = true;
if ($this->debug) print($this->debugbeg . "ogg('$file')<HR>\n");

$this->file = $file;
$this->_read();

if ($this->debug) print($this->debugend);
} // ogg($file)

/*
* _read() - finds the comment in a ogg stream. You should not call this.
*/
function _read() {
if ($this->debug) print($this->debugbeg . "_read()<HR>\n");

if (! ($f = fopen($this->file, 'rb')) ) {
$this->error = 'Unable to open ' . $file;
if ($this->debug) print("<B>$this->error</B>$this->debugend");
return false;
}

$this->_find_page($f);
$this->_find_page($f);

fseek($f, 26 - 4, SEEK_CUR);
$segs = fread($f, 1);
$segs = unpack('C1size', $segs);
$segs = $segs['size'];
if ($this->debug) print("segs: $segs<BR>");
fseek($f, $segs, SEEK_CUR);

// Skip preable
//$r = fread($f, 1);
//print_r(unpack('H*raw', $r));
fseek($f, 7, SEEK_CUR);

// Skip Vendor
$size = fread($f, 4);
$size = unpack('V1size', $size);
$size = $size['size'];
if ($this->debug) print("vendor size: $size<BR>");
fseek($f, $size, SEEK_CUR);

// Comments
$comments = fread($f, 4);
$comments = unpack('V1comments', $comments);
$comments = $comments['comments'];
if ($this->debug) print("Comments: $comments<BR>");
for ($i=0; $i < $comments; $i++) {
$size = fread($f, 4);
$size = unpack('V1size', $size);
$size = $size['size'];
if ($this->debug) print("comment size: $size<BR>");

$comment = fread($f, $size);
if ($this->debug) print("comment: $comment<BR>");
$comment = explode('=', $comment, 2);
$this->fields[strtoupper($comment[0])][] = $comment[1];
$this->_rawfields[] = $comment;
}

if ($this->debug) print($this->debugend);
} // _read()

/*
* _find_page - seeks to the next ogg page start.
*/
function _find_page(&$f) {
if ($this->debug) print($this->debugbeg . "_find_page($f)<HR>\n");

$header = 'OggS'; // 0xf4 . 0x67 . 0x 67 . 0x53
$bytes = fread($f, 4);

while ($header != $bytes) {
//if ($this->debug) print('.');
$bytes = substr($bytes, 1);
$bytes .= fread($f, 1);
}

if ($this->debug) {
echo 'Page found at byte: ', ftell($f) - 4, '<BR>';
print($this->debugend);
}
} // _find_page(&$file)

} // end of class ogg

?>
2003년 01월 25일 21:39:48 토(저녁)  from 61.254.75.40
File ☆ 자료(파일:class_ogg_php.txt)가 있는 글입니다. !!!
0
암호: 공용 보안 SSL 서버가 준비되기 전까지는 off 합니다

apache lighttpd linuxchannel.net 
Copyright 1997-2026. linuxchannel.net. All rights reserved.

Page loading: 0.01(server) + (network) + (browser) seconds