>> Forum
![]() ![]() |
Sep 1 2009, 10:27 AM
Post
#1
|
|
|
Advanced Member ![]() ![]() ![]() Group: Members Posts: 30 Joined: 18-June 08 Member No.: 34 |
I've written this just for testing:
CODE <?php class epjStream { var $position = 0, $resource; function sanitize($c) { if(strpos($c,'<?')!==false&&strpos($c,';')!==false) { $a = array('ú','ã','á','ê','é','ç','ó','â','ê','ç','ú','ó','ã','É','õ','õ','ô','Ü','°','ñ'); $b = array('ú', 'ã', 'á', 'ê', 'é', 'ç', 'ó', 'â', 'ê', 'ç', 'ú', 'ó', 'ã', 'É', 'õ', 'õ', 'ô', 'Ü', '°', 'ñ' ); $c = utf8_decode(str_replace($a, $b, $c)); } return $c; } function parse($path) { $path = str_replace(array('\\','epj://'),array('/',''),$path); $file = substr($path, 0, strrpos($path,'#')); $section = substr($path, strrpos($path,'#')+1); return compact('file', 'section'); } function stream_open($path, $mode, $options, &$opened_path) { $path = $this->parse($path); extract($path); if(!isset($GLOBALS[$file])) { $GLOBALS[$file] = array(); if($buffer = file_get_contents($file)) { $buffer = explode('<resource>', $buffer); foreach($buffer as $fragment) { if(stripos('<data', $fragment)!==false) continue; $name = explode('name>', $fragment); $type = explode('type>', $fragment); $data = explode('data>', $fragment); if(sizeof($data)>1) { $name = substr($name[1], 0, -2); $type = substr($type[1], 0, -2); $data = substr($data[1], 0, -2); $GLOBALS[$file][$type.'/'.$name] = $this->sanitize(base64_decode($data)); } } } } $this->resource = isset($GLOBALS[$file][$section])?$GLOBALS[$file][$section]:''; return true; } function stream_read($count) { $ret = substr($this->resource, $this->position, $count); $this->position += strlen($ret); return $ret; } function stream_stat() { return array('dev'=>771,'ino'=>488704,'mode'=>33188,'nlink'=>1,'uid'=>0,'gid'=>0,'rdev'=>0,'size'=>strlen($this->resource),'atime'=>time(),'mtime' => time(),'ctime' => time(),'blksize' => 4096,'blocks' => 8); } function stream_write($data) { return false; } function stream_tell() { return $this->position; } function stream_eof() { return $this->position >= strlen($this->resource); } function stream_seek($o, $w =0 ) { $this->position = $o + $w; return true; } } stream_wrapper_register('epj', 'epjStream') or die('Failed to register epj protocol'); include_once('epj://megacubo.epj#PHP/MAIN'); echo file_get_contents("epj://C:\\teste.epj#TXT/DATA"); ?> The sanitize function I've added just to prevent some strange UTF8 chars that was in my testing project and may be removed. If you have better solutions post here! -------------------- Sorry for my poor english... ^^
|
|
|
|
Sep 1 2009, 09:03 PM
Post
#2
|
|
|
Administrator ![]() ![]() ![]() Group: Root Admin Posts: 47 Joined: 23-July 07 Member No.: 1 |
I like it
You always happen to surprise me, keep it up! |
|
|
|
![]() ![]() |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
| Lo-Fi Version | Time is now: 10th September 2010 - 06:34 AM |




Sep 1 2009, 10:27 AM


