\n"; if($biBitCount<24) { $img=imagecreate($Width,$Height); $Colors=pow(2,$biBitCount); for($p=0;$p<$Colors;$p++) { $B=freadbyte($bitmapdata, $BMP_POS); $G=freadbyte($bitmapdata, $BMP_POS); $R=freadbyte($bitmapdata, $BMP_POS); $Reserved=freadbyte($bitmapdata, $BMP_POS); $Palette[]=imagecolorallocate($img,$R,$G,$B); } } else { $img=imagecreatetruecolor($Width,$Height); } if ($img === FALSE) return NULL; // unable to create an image for some reason $BMP_POS = $FirstByteOfImage; // 20081202pjy if($RLECompression==0 && $biBitCount < 24) { $start = $BMP_POS; $pixels_per_byte = intval(8 / $biBitCount); $linewidth = floor(floor(floor($Width + $pixels_per_byte - 1) / $pixels_per_byte + 3) / 4) * 4; for($y=$Height-1;$y>=0;$y--) { $BMP_POS = $start; $bits = 0; $bitbuffer = 0; for($x=0;$x<$Width;$x++) { $C=GetBits($bitmapdata, $BMP_POS, $biBitCount, $bits, $bitbuffer); imagesetpixel($img,$x,$y,$Palette[$C]); } $start += $linewidth; } } elseif ($RLECompression == 1) { //$BI_RLE8 $y=$Height; $pocetb=0; while(true) { $y--; $prefix=freadbyte($bitmapdata, $BMP_POS); $suffix=freadbyte($bitmapdata, $BMP_POS); $pocetb+=2; if(($prefix==0)and($suffix==1)) break; if($BMP_POS >= $BMP_MAX) break; $Data=''; while(!(($prefix==0)and($suffix==0))) { if($prefix==0) { $pocet=$suffix; // $Data.=fread($f,$pocet); $Data .= substr($bitmapdata, $BMP_POS, $pocet); $BMP_POS += $pocet; $pocetb+=$pocet; if($pocetb%2==1) {freadbyte($bitmapdata, $BMP_POS); $pocetb++;} } if($prefix>0) { $pocet=$prefix; for($r=0;$r<$pocet;$r++) $Data.=chr($suffix); } $prefix=freadbyte($bitmapdata, $BMP_POS); $suffix=freadbyte($bitmapdata, $BMP_POS); $pocetb+=2; } for($x=0;$x= $BMP_MAX) break; $Data=''; while(!(($prefix==0)and($suffix==0))) { if($prefix==0) { $pocet=$suffix; $CurrentBit=0; for($h=0;$h<$pocet;$h++) $Data.=chr(freadbits($bitmapdata, $BMP_POS, 4)); if($CurrentBit!=0) freadbits($bitmapdata, $BMP_POS,4); $pocetb+=ceil(($pocet/2)); if ($pocetb % 2 == 1) { freadbyte($bitmapdata, $BMP_POS); $pocetb++; } } if($prefix>0) { $pocet=$prefix; $i=0; for($r=0;$r<$pocet;$r++) { if ($i % 2 == 0) { $Data.=chr($suffix%16); } else { $Data.=chr(floor($suffix/16)); } $i++; } } $prefix=freadbyte($bitmapdata, $BMP_POS); $suffix=freadbyte($bitmapdata, $BMP_POS); $pocetb+=2; } for($x=0;$x=0;$y--) { for($x=0;$x<$Width;$x++) { $B=freadbyte($bitmapdata, $BMP_POS); $G=freadbyte($bitmapdata, $BMP_POS); $R=freadbyte($bitmapdata, $BMP_POS); $color=imagecolorexact($img,$R,$G,$B); if($color==-1) $color=imagecolorallocate($img,$R,$G,$B); imagesetpixel($img,$x,$y,$color); } for($z=0;$z<$Zbytek;$z++) freadbyte($bitmapdata, $BMP_POS); } } return $img; }; /* * Helping functions: *------------------------- * * freadbyte($file) - reads 1 byte from $file * freadword($file) - reads 2 bytes (1 word) from $file * freaddword($file) - reads 4 bytes (1 dword) from $file * freadlngint($file) - same as freaddword($file) */ function freadbyte(&$bitmapdata, &$BMP_POS) { global $BMP_MAX; if ($BMP_POS >= $BMP_MAX) return 0; $r = ord($bitmapdata[$BMP_POS]); $BMP_POS++; return $r; } function freadword(&$bitmapdata, &$BMP_POS) { $b1=freadbyte($bitmapdata, $BMP_POS); $b2=freadbyte($bitmapdata, $BMP_POS); return $b2*256+$b1; } function freaddword(&$bitmapdata, &$BMP_POS) { $b1=freadword($bitmapdata, $BMP_POS); $b2=freadword($bitmapdata, $BMP_POS); return $b2*65536+$b1; } function GetBits(&$bitmapdata, &$BMP_POS, $biBitCount, &$bits, &$bitbuffer) { while ($bits < $biBitCount) { $bitbuffer = $bitbuffer << 8 | freadbyte($bitmapdata, $BMP_POS, 1); $bits += 8; } $bits -= $biBitCount; $value = $bitbuffer >> $bits; $mask = (1 << $biBitCount) - 1; return $value & $mask; } /* function imagecreatefromtga ( $filename, $return_array = 0 ) { $handle = fopen ( $filename, 'rb' ); $data = fread ( $handle, filesize( $filename ) ); fclose ( $handle ); $pointer = 18; $x = 0; $y = 0; $w = base_convert ( bin2hex ( strrev ( substr ( $data, 12, 2 ) ) ), 16, 10 ); $h = base_convert ( bin2hex ( strrev ( substr ( $data, 14, 2 ) ) ), 16, 10 ); $img = imagecreatetruecolor( $w, $h ); while ( $pointer < strlen ( $data ) ) { imagesetpixel ( $img, $x, $y, base_convert ( bin2hex ( strrev ( substr ( $data, $pointer, 3 ) ) ), 16, 10 ) ); $x++; if ($x == $w) { $y++; $x=0; } $pointer += 3; } if ( $return_array ) return array ( $img, $w, $h ); else return $img; } */ ?> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ class phpHTMLparse { var $tag_handler, $content_handler; var $position; var $ABORT; var $replace_lf = 1; function phpHTMLparse($handletag_func=NULL, $handlecontent_func=NULL) { /* Setup default handlers if none specified */ $this->ABORT = 0; if ($handletag_func===NULL) $handletag_func='handle_tag'; if ($handlecontent_func==NULL) $handlecontent_func='handle_content'; $this->set_handlers($handletag_func, $handlecontent_func); } function set_handlers($tag, $content) { /* Sets up the handlers */ $this->set_tag_handler($tag); $this->set_content_handler($content); } function set_content_handler($handlecontent_func) { /* Set the content handler */ /* Check if there is a locally defined method for the handler (extended), then check global, abort if none. */ if (method_exists($this, $handlecontent_func)) { $this->content_handler=array('SCOPE'=>'METHOD', 'FUNC'=>$handlecontent_func); } else if (function_exists($handlecontent_func)) { $this->content_handler=array('SCOPE'=>'FUNCTION', 'FUNC'=>$handlecontent_func); } else { $this->content_handler=NULL; user_error('No content handlers defined!!', E_USER_ERROR); } } function set_tag_handler($handletag_func) { /* Set the tag handler */ /* Check if there is a locally defined method for the handler (extended), then check global, abort if none. */ if (method_exists($this, $handletag_func)) { $this->tag_handler=array('SCOPE'=>'METHOD', 'FUNC'=>$handletag_func); } else if (function_exists($handletag_func)) { $this->tag_handler=array('SCOPE'=>'FUNCTION', 'FUNC'=>$handletag_func);; } else { $this->tag_handler=NULL; user_error('No tag handlers defined!!', E_USER_ERROR); } } function parse($s) { if (!$this->tag_handler || !$this->content_handler) { user_error('Not parsing. Not all handlers defined!!', E_USER_ERROR); return FALSE; } /* Add one opening < to the end just to force parse to force the output, otherwise it would have to do work when main loop ends. */ $s.='<'; $len=strlen($s); $lastmark=0; $curs=''; $gotopen=FALSE; $this->position = 0; $current_tag = ''; $line = $this->line = 1; for ($i=0; $i<$len && !$this->ABORT; $i++) { switch ($s[$i]) { case '<': /* If we are already in a < (unclosed) then this < is just an extra one */ if ($gotopen) { $curs.=$s[$i]; continue; } if (substr($s, $i, 4) == ''); continue; } $gotopen=TRUE; if ($curs=='') continue; /* Check if we should be calling a local method or a global function */ if ($this->content_handler['SCOPE']=='METHOD') $this->{$this->content_handler['FUNC']}($curs); else if ($this->content_handler['SCOPE']=='FUNCTION') $this->content_handler['FUNC']($curs); $this->position = $i; $this->line = $line; $curs=''; break; case '>': /* If we are not in an opening tag, then this is just a wondering > */ if (!$gotopen) { $curs.=$s[$i]; continue; } $data=$this->_parse_tag($curs); $uppervariables=array(); /* Setup an arrray of all the variables in upper case (references) */ foreach ($data['VARIABLES'] as $k=>$v) { $uppervariables[strtoupper($k)]=&$data['VARIABLES'][$k]; } $data['UPPERVARIABLES']=$uppervariables; $data['RAWTAG']="<$curs>"; /* Check if we should be calling a local method or a global function */ if ($this->tag_handler['SCOPE']=='METHOD') $this->{$this->tag_handler['FUNC']}($data); else if ($this->tag_handler['SCOPE']=='FUNCTION') $this->tag_handler['FUNC']($data); $this->position = $i; $this->line = $line; $curs=''; $gotopen=FALSE; $current_tag = $data['UPPERTAG']; if ($current_tag == 'SCRIPT' || $current_tag == 'STYLE') { $curs = $this->skip_data($s, $i, $gotopen, ' and is treated as content } break; default: if ($s{$i} == "\n") $line++; if ($s{$i} == "\n" && $gotopen && $this->replace_lf) { $curs .= ' '; //PJY } else { $curs .= $s[$i]; } break; } } } //everything between is treated as content function skip_data(&$s, &$i, &$gotopen, $end_tag) { $pos = stripos($s, $end_tag, $i); // find the corresponding close tag if ($pos === FALSE) return; // no closing tag found - do nothing // get the content between open/close tags if ($end_tag == '-->') { $curs = substr($s, $i, $pos - $i + 3); $i--; } else { $curs = substr($s, $i + 1, $pos - $i - 1); } $i += strlen($curs); return $curs; } /* Converts all the variables in $tag["VARIABLS"] back to var1="blah1" var2="blah2" */ function variable_string($variables) { $args=''; foreach ($variables as $k=>$v) { /* Make sure we quote the variables with the original quoter, if any. Just incase they used ' instead of " or maybe they didnt use any! */ $quotewith=$v['QUOTEWITH']; $val=$v['VALUE']; if ($v['NOVALUE']) $args.="$k "; else $args.="$k=${quotewith}$val${quotewith} "; } /* Byebye extra space, return */ return substr($args, 0, -1); } function _parse_tag($tagline) { $spacing=array(' ', "\t", "\r", "\n"); $quoters=array("'", '"'); /* Add an extra white space to the end of the tagline, just to make sure the loop reaches all points of the pass data */ $tagline.= ' '; $dat=array(); $dat['VARIABLES']=array(); $i=strpos($tagline, ' '); if ($i===FALSE) { /* If we did not find a space, then this is just a tag like
, store it and return below. */ $dat['TAG']=$tagline; } else { $dat['TAG']=substr($tagline, 0, $i); } /* Store upper case version of the tag, easier for user handlers */ $dat['UPPERTAG']=strtoupper($dat['TAG']); if ($i===FALSE) return $dat; /* Return if we did not find a " " in the original string */ $len=strlen($tagline); $varname=''; $value=''; $state='VAR'; $closeon=NULL; for ($i++; $i<$len; $i++) { $c=$tagline[$i]; if ($state=='VAR') { /* If we reached white space while in var mode, that means its just a single name. () */ if (in_array($c, $spacing)) { $state='VAR'; $dat['VARIABLES'][$varname]=array('VALUE'=>NULL, 'NOVALUE'=>TRUE, 'QUOTEWITH'=>NULL); $value=''; $varname=''; if ($c==$closeon) $i++; } else if ($c=='=') { /* We got a name=value pair */ $state='VAL'; $temp=$i; $temp++; /* Skip over any extra white space */ while ($len>$temp && in_array($tagline[$temp], $spacing)) { $temp++; } /* If we skipped over space, then set $i to where we skipped to */ if ($temp!=($i+1)) $i=$temp; $closeon=NULL; /* Do we have a quoter (', ")? If so, store it so we know what to close on. */ if (in_array($tagline[$i+1], $quoters)) { $closeon=$tagline[$i+1]; $i++; } } else { $varname.=$c; } } else if ($state=='VAL') { /* If we got $close on (", ') or closein is NULL and this is white space */ if ($c==$closeon || ($closeon==NULL && (in_array($c, $spacing)))) { $state='VAR'; $dat['VARIABLES'][$varname]=array('VALUE'=>$value, 'NOVALUE'=>FALSE, 'QUOTEWITH'=>$closeon); $value=''; $varname=''; if ($c==$closeon) { if (in_array($tagline[$i+1], $spacing)) $i++; // only skip, if it is a white space } } else { $value.=$c; } } } return $dat; } } ?>phpHTMLparse(); } function processLink($url) { global $aid; $prefix = ''; if (($p = strpos($url, '#')) !== FALSE) { $prefix = substr($url, $p); $url = substr($url, 0, $p); } $url = str_replace("\\", '/', $url); if ((strpos($url, '://') === FALSE) && ($url != '') ) { // have we a local URL? if ($url{0} == '/') $url = substr($url, 1); // absolute -> relative if (substr($url, 0, 2) == './') $url = substr($url, 2); // remove reference to current directory // Locate the image in the archive, replace image name with an index $id = $this->GetFileID($this->parentid, strtolower($url)); $aid = $this->archive; if ($id != '') $url = "/archive/$aid/image/$id"; } return $url . $prefix; } function GetFileID($thisnode, $fullpath) { global $DATABASE; $aid = $this->archive; $data = $DATABASE->Lookup("select dd_text from d62_directory where dd_aid=$aid and dd_node=$thisnode"); $tree = array(); @eval('$tree=' . $data['dd_text'] . ';'); $id = ''; $elements = explode('/', $fullpath); $item = array_shift($elements); $c = count($tree); for($i=0;$i<$c && $id=='';$i++) { // echo $tree[$i]['name'] . ' / ' . $item . "
\n"; if (strtolower($tree[$i]['name']) == $item) { if (!count($elements)) { $id = $thisnode . '-' . $tree[$i]['num']; } else { $temp = implode('/', $elements); if (isset($tree[$i]['child'])) { $id = $this->GetFileID($tree[$i]['child'], $temp); } } } } return $id; } function handle_tag($dat) { $raw = strtolower($dat['TAG']); $r = '<' . $dat['TAG']; foreach ($dat['UPPERVARIABLES'] as $k => $v) { if ($k == 'SRC' && $raw == 'img') { $r .= ' src=' . $v['QUOTEWITH'] . $this->processLink($v['VALUE']). $v['QUOTEWITH']; } elseif ($k == 'HREF' && $raw == 'a') { $r .= ' href=' . $v['QUOTEWITH']. $this->processLink($v['VALUE']) . $v['QUOTEWITH']; } elseif ($v['NOVALUE']) { $r .= ' ' . strtolower($k); } else { $r .= ' ' . strtolower($k) . '=' . $v['QUOTEWITH'] . $v['VALUE'] . $v['QUOTEWITH']; } } $this->newhtml .= $r . '>'; return TRUE; } function handle_content($dat) { $this->newhtml .= $dat; return TRUE; } function process($data) { $this->newhtml=''; $this->parse($data); return $this->newhtml; } } function icvp_ConvertHTML($parentid, $aid, $source) { $cdump = new phpHTMLproc(); $cdump->parentid = $parentid; $cdump->archive = $aid; $textmessage = $cdump->process($source); unset($cdump); return $textmessage; } function icvp_ConvertRTF($source) { $r = new rtf($source); $r->output('html'); $r->parse(); $c = count($r->err); if (!$c) { // no errors detected $result = "{$r->outstyles}" . $r->out . ""; } else { if ($c == 1) { $result = 'an error occured when converting RTF to HTML'; } else { $result = "$c errors occured when converting RTF to HTML"; } $errs = ''; foreach($r->err as $err) { $errs .= "
  • $err
  • \n"; } $result = "

    $result

      $errs
    "; } unset($r); return $result; } http://josefine.ben.tuwien.ac.at/~mfischer/ Latest versions of this class can always be found at http://josefine.ben.tuwien.ac.at/~mfischer/developing/php/rtf/rtfclass.phps Testing suite is available at http://josefine.ben.tuwien.ac.at/~mfischer/developing/php/rtf/ License: GPLv2 Specification: http://msdn.microsoft.com/library/default.asp?URL=/library/specs/rtfspec.htm General Notes: ============== Unknown or unspupported control symbols are silently gnored Group stacking is still not supported :( group stack logic implemented; however not really used yet Example on how to use this class: ================================= $r = new rtf( stripslashes( $rtf)); $r->output( "xml"); $r->parse(); if( count( $r->err) == 0) // no errors detected echo $r->out; History: ======== Sat Nov 25 09:52:12 CET 2000 mfischer First version which has useable but only well-formed xml output; rtf data structure is only logically rebuild, no real parsing yet Mon Nov 27 16:17:18 CET 2000 mfischer Wrote handler for \plain control word (thanks to Peter Kursawe for this one) Tue Nov 28 02:22:16 CET 2000 mfischer Implemented alignment (left, center, right) with HTML
    character when outputting html or xml Mon Oct 25 14:15:03 CET 2004 smanciles Implemented parsing of special characteres for spanish and catalan (úÃ...) Remarks: ======== This class and all work done here is dedicated to Tatjana. */ /* was just a brainlag suggestion of my inner link; don't know if I'll use it */ class rtfState { var $bold; var $italic; var $underlined; } class rtf { var $rtf; // rtf core stream var $len; // length in characters of the stream (get performace due avoiding calling strlen everytime) var $err = array(); // array of error message, no entities on no error var $wantXML; // convert to XML var $wantHTML; // convert to HTML // the only variable which should be accessed from the outside var $out; // output data stream (depends on which $wantXXXXX is set to true var $outstyles; // htmlified styles (generated after parsing if wantHTML var $styles; // if wantHTML, stylesheet definitions are put in here // internal parser variables -------------------------------- // control word variables var $cword; // holds the current (or last) control word, depending on $cw var $cw; // are we currently parsing a control word ? var $cfirst; // could this be the first character ? so watch out for control symbols var $flags = array(); // parser flags var $queue; // every character which is no sepcial char, not belongs to a control word/symbol; is generally considered being 'plain' var $stack = array(); // group stack /* keywords which don't follw the specification (used by Word '97 - 2000) */ // not yet used var $control_exception = array( "clFitText", "clftsWidth(-?[0-9]+)?", "clNoWrap(-?[0-9]+)?", "clwWidth(-?[0-9]+)?", "tdfrmtxtBottom(-?[0-9]+)?", "tdfrmtxtLeft(-?[0-9]+)?", "tdfrmtxtRight(-?[0-9]+)?", "tdfrmtxtTop(-?[0-9]+)?", "trftsWidthA(-?[0-9]+)?", "trftsWidthB(-?[0-9]+)?", "trftsWidth(-?[0-9]+)?", "trwWithA(-?[0-9]+)?", "trwWithB(-?[0-9]+)?", "trwWith(-?[0-9]+)?", "spectspecifygen(-?[0-9]+)?" ); var $charset_table = array( "0" => "ANSI", "1" => "Default", "2" => "Symbol", "77" => "Mac", "128" => "Shift Jis", "129" => "Hangul", "130" => "Johab", "134" => "GB2312", "136" => "Big5", "161" => "Greek", "162" => "Turkish", "163" => "Vietnamese", "177" => "Hebrew", "178" => "Arabic", "179" => "Arabic Traditional", "180" => "Arabic user", "181" => "Hebrew user", "186" => "Baltic", "204" => "Russion", "222" => "Thai", "238" => "Eastern European", "255" => "PC 437", "255" => "OEM" ); /* note: the only conversion table used */ var $fontmodifier_table = array( "bold" => "b", "italic" => "i", "underlined" => "u", "strikethru" => "strike" ); /* Class Constructor: Takes as argument the raw RTF stream (Note under certain circumstances the stream has to be stripslash'ed before handling over) Initialises some class-global variables */ function rtf( $data) { $this->len = strlen( $data); $this->rtf = $data; $this->wantXML = false; $this->wantHTML = false; $this->out = ''; $this->outstyles = ''; $this->styles = array(); $this->text = ''; if( $this->len == 0) array_push( $this->err, "No data in stream found"); } function parserInit() { /* Default values according to the specs */ $this->flags = array( "fontsize" => 24, 'beginpar' => 1 ); } /* Sets the output type */ function output( $typ) { switch( $typ) { case "xml": $this->wantXML = true; break; case "html": $this->wantHTML = true; break; default: break; } } function parseControl( $control, $parameter) { // echo "$control $parameter
    \n"; switch( $control) { // font table definition start case "fonttbl": $this->flags["fonttbl"] = true; // signal fonttable control words they are allowed to behave as expected break; // define or set font case "f": if( $this->flags["fonttbl"]) { // if its set, the fonttable definition is written to; else its read from $this->flags["fonttbl_current_write"] = $parameter; } else { $this->flags["fonttbl_current_read"] = $parameter; } break; case "fcharset": // this is for preparing flushQueue; it then moves the Queue to $this->fonttable .. instead to formatted output $this->flags["fonttbl_want_fcharset"] = $parameter; break; case "fs": // sets the current fontsize; is used by stylesheets (which are therefore generated on the fly $this->flags["fontsize"] = $parameter; break; // handle alignment case "qc": $this->flags["alignment"] = "center"; break; case "qr": $this->flags["alignment"] = "right"; break; // reset paragraph settings ( only alignment) case "pard": $this->flags["alignment"] = ""; break; case 'line': // 20050823 if( $this->wantHTML) $this->out .= '
    '; break; case 'tab' : // should be a tab, but here we're putting in a space if( $this->wantHTML) { $this->out .= '   '; } break; // define new paragraph (for now, thats a simple break in html) case 'par': // begin new line if( $this->wantHTML) { // $this->out .= "
    "; $this->out .= '

    '; } $this->flags['beginpar'] = 1; break; // bold case 'bnone': $parameter = 0; case 'b': $this->flags['bold'] = ($parameter) ? 1 : 0; break; // underlined case 'ulnone': $parameter = 0; case 'ul': $this->flags['underlined'] = ($parameter) ? 1 : 0; break; // italic case 'inone': $parameter = 0; case "i": $this->flags['italic'] = ($parameter) ? 1 : 0; break; // strikethru case 'strikenone': $parameter = 0; case 'strike': $this->flags['strikethru'] = ($parameter) ? 1 : 0; break; // reset all font modifiers and fontsize to 12 case 'plain': $this->flags['bold'] = 0; $this->flags['italic'] = 0; $this->flags['underlined'] = 0; $this->flags['strikethru'] = 0; $this->flags["fontsize"] = 12; $this->flags['subscription'] = 0; $this->flags['superscription'] = 0; break; // sub and superscription case 'subnone': $parameter = 0; case 'sub': $this->flags['subscription'] = ($parameter) ? 1 : 0; break; case 'supernone': $parameter = 0; case 'super': $this->flags['superscription'] = ($parameter) ? 1 : 0; break; } } /* Dispatch the control word to the output stream */ function flushControl() { if( ereg( "^([A-Za-z]+)(-?[0-9]*) ?$", $this->cword, $match)) { if (is_bool($match[2])) $match[2] = ($match[2]) ? 0 : 1; $this->parseControl( $match[1], $match[2]); if( $this->wantXML) { $this->out.=" 0) $this->out.=" param=\"".$match[2]."\""; $this->out.="/>"; } } } /* If output stream supports comments, dispatch it */ function flushComment( $comment) { if( $this->wantXML || $this->wantHTML) { $this->out.=""; } } /* Dispatch start/end of logical rtf groups (not every output type needs it; merely debugging purpose) */ function flushGroup( $state) { if( $state == "open") { /* push onto the stack */ array_push( $this->stack, $this->flags); if( $this->wantXML) $this->out.=""; } if( $state == "close") { /* pop from the stack */ $this->last_flags = $this->flags; $this->flags = array_pop( $this->stack); $this->flags["fonttbl_current_write"] = ""; // on group close, no more fontdefinition will be written to this id // this is not really the right way to do it ! // of course a '}' not necessarily donates a fonttable end; a fonttable // group at least *can* contain sub-groups // therefore an stacked approach is heavily needed $this->flags["fonttbl"] = false; // no matter what you do, if a group closes, its fonttbl definition is closed too if( $this->wantXML) $this->out.=""; } } function flushHead() { if( $this->wantXML) $this->out.=""; } function flushBottom() { if( $this->wantXML) $this->out.=""; } function checkHtmlSpanContent( $command) { reset( $this->fontmodifier_table); while( list( $rtf, $html) = each( $this->fontmodifier_table)) { if(isset($this->flags[$rtf]) && ($this->flags[$rtf] == true)) { // 20050823 if( $command == "start") $this->out .= "<$html>"; else $this->out .= ""; } } } /* flush text in queue */ function flushQueue() { if( strlen( $this->queue)) { // processing logic if (!isset($this->flags['fonttbl_want_fcharset'])) $this->flags['fonttbl_want_fcharset'] = ''; // 20050823 if( ereg( "^[0-9]+$", $this->flags["fonttbl_want_fcharset"])) { $this->fonttable[$this->flags["fonttbl_want_fcharset"]]["charset"] = $this->queue; $this->flags["fonttbl_want_fcharset"] = ""; $this->queue = ""; } // output logic if( strlen( $this->queue)) { /* Everything which passes this is (or, at leat, *should*) be only outputted plaintext Thats why we can safely add the css-stylesheet when using wantHTML */ if( $this->wantXML) $this->out.= "".$this->queue.""; if( $this->wantHTML) { if (!isset($this->flags['fonttbl_current_read'])) $this->flags['fonttbl_current_read'] = ''; // 20050823 // only output html if a valid (for now, just numeric;) fonttable is given if( ereg( "^[0-9]+$", $this->flags["fonttbl_current_read"])) { if (!isset($this->flags['beginpar'])) { $this->flags['beginpar'] = 0; } if( $this->flags['beginpar']) { $this->flags['beginpar'] = 0; /* $this->out .= "
    flags['alignment'])) { // 20050823 $this->out .= 'left'; } else { switch( $this->flags['alignment']) { case "right": $this->out .= "right"; break; case "center": $this->out .= "center"; break; case "left": default: $this->out .= "left"; } } $this->out .= "\">"; */ } /* define new style for that span */ $family = isset($this->fonttable[$this->flags['fonttbl_current_read']]['charset']) ? // 20050823 $this->fonttable[$this->flags['fonttbl_current_read']]['charset'] : 'Arial'; $this->styles["f".$this->flags["fonttbl_current_read"]."s".$this->flags["fontsize"]] = "font-family:".$family . " font-size:".$this->flags["fontsize"].";"; /* write span start */ $this->out .= "flags["fonttbl_current_read"]."s".$this->flags["fontsize"]."\">"; /* check if the span content has a modifier */ $this->checkHtmlSpanContent( "start"); /* write span content */ $this->out .= $this->queue; /* close modifiers */ $this->checkHtmlSpanContent( "stop"); /* close span */ $this->out .= ""; // 20050823 } } $this->queue = ""; } } } /* handle special charactes like \'ef */ function flushSpecial( $special) { if( strlen( $special) == 2) { if( $this->wantXML) $this->out .= ""; if( $this->wantHTML){ // $this->out .= ""; switch( $special) { case "c1": $this->out .= "Á"; break; case "e1": $this->out .= "á"; break; case "c0": $this->out .= "À"; break; case "e0": $this->out .= "à"; break; case "c9": $this->out .= "É"; break; case "e9": $this->out .= "é"; break; case "c8": $this->out .= "È"; break; case "e8": $this->out .= "è"; break; case "cd": $this->out .= "Í"; break; case "ed": $this->out .= "í"; break; case "cc": $this->out .= "Ì"; break; case "ec": $this->out .= "ì"; break; case "d3": $this->out .= "Ó"; break; case "f3": $this->out .= "ó"; break; case "d2": $this->out .= "Ò"; break; case "f2": $this->out .= "ò"; break; case "da": $this->out .= "Ú"; break; case "fa": $this->out .= "ú"; break; case "d9": $this->out .= "Ù"; break; case "f9": $this->out .= "ù"; break; case "80": $this->out .= "€"; break; case "d1": $this->out .= "Ñ"; break; case "f1": $this->out .= "ñ"; break; case "c7": $this->out .= "Ç"; break; case "e7": $this->out .= "ç"; break; case "dc": $this->out .= "Ü"; break; case "fc": $this->out .= "ü"; break; case "bf": $this->out .= "¿"; break; case "a1": $this->out .= "¡"; break; case "b7": $this->out .= "·"; break; case "a9": $this->out .= "©"; break; case "ae": $this->out .= "®"; break; case "ba": $this->out .= "º"; break; case "aa": $this->out .= "ª"; break; case "b2": $this->out .= "²"; break; case "b3": $this->out .= "³"; break; } } } } /* Output errors at end */ function flushErrors() { if( count( $this->err) > 0) { if( $this->wantXML) { $this->out .= ""; while( list($num,$value) = each( $this->err)) { $this->out .= "".$value.""; } $this->out .= ""; } } } function makeStyles() { $this->outstyles = "\n"; } /* finally .. How this parser (is supposed) to work: ====================================== This parse simple starts at the beginning of the rtf core stream, catches every controlling character {,} and \, automatically builds control words and control symbols during his livetime, trashes every other character into the plain text queue */ function parse() { $this->parserInit(); $i = 0; $this->cw= false; // flag if control word is currently parsed $this->cfirst = false; // first control character ? $this->cword = ''; // last or current control word ( depends on $this->cw $this->queue = ''; // plain text data found during parsing $this->flushHead(); while( $i < $this->len) { switch( $this->rtf[$i]) { case "{": if( $this->cw) { $this->flushControl(); $this->cw= false; $this->cfirst = false; } else $this->flushQueue(); $this->flushGroup( "open"); break; case "}": if( $this->cw) { $this->flushControl(); $this->cw= false; $this->cfirst = false; } else $this->flushQueue(); $this->flushGroup( "close"); break; case "\\": if( $this->cfirst) { // catches '\\' $this->queue .= '\\'; $this->cfirst = false; $this->cw= false; break; } if( $this->cw) { $this->flushControl(); } else $this->flushQueue(); $this->cw = true; $this->cfirst = true; $this->cword = ''; break; default: if( (ord( $this->rtf[$i]) == 10) || (ord($this->rtf[$i]) == 13)) break; // eat line breaks if( $this->cw) { // active control word ? /* Watch the RE: there's an optional space at the end which IS part of the control word (but actually its ignored by flushControl) */ if( ereg( "^[a-zA-Z0-9-]?$", $this->rtf[$i])) { // continue parsing $this->cword .= $this->rtf[$i]; $this->cfirst = false; } else { /* Control word could be a 'control symbol', like \~ or \* etc. */ $specialmatch = false; if( $this->cfirst) { if( $this->rtf[$i] == '\'') { // expect to get some special chars $this->flushQueue(); $this->flushSpecial( $this->rtf[$i+1].$this->rtf[$i+2]); $i+=2; $specialmatch = true; $this->cw = false; $this->cfirst = false; $this->cword = ""; } if ($this->rtf[$i] == '*') { // 20050823 $specialmatch = true; } elseif( ereg( "^[{}\*]$", $this->rtf[$i])) { // $this->flushComment( "control symbols not yet handled"); $this->flushComment( $this->rtf[$i] . ' ignored'); $specialmatch = true; } $this->cfirst = false; } else { if( $this->rtf[$i] == ' ') { // space delimits control words, so just discard it and flush the controlword $this->cw = false; $this->flushControl(); break; } } if( ! $specialmatch) { $this->flushControl(); $this->cw = false; $this->cfirst = false; /* The current character is a delimeter, but is NOT part of the control word so we hop one step back in the stream and process it again */ $i--; } } } else { // < and > need translation before putting into queue when XML or HTML is wanted if( ($this->wantHTML) || ($this->wantXML)) { switch( $this->rtf[$i]) { case '&': // 20050823 $this->queue .= '&'; break; case '<': $this->queue .= '<'; break; case '>': $this->queue .= '>'; break; default: $this->queue .= $this->rtf[$i]; break; } } else $this->queue .= $this->rtf[$i]; } } $i++; } $this->flushQueue(); $this->flushErrors(); $this->flushBottom(); if( $this->wantHTML) { $this->makeStyles(); } } } ?> NETGEAR RangeMax(tm) NEXT Wireless Adapter WN311B - DriverAgent.com

    User Testimonials

    "Man!!! What a time saver! So easy and comprehensive. Keep up the good work."
    -Bill H.

    » read more

    The following is a preview of wn311b.inf in Archive 0deba5cd:

    You Found It!

    Start the Download Process Here:

    Option 1

    Use DriverAgent to download this driver and find other outdated drivers for your PC.


    FREE DRIVER SCAN - Click Here to Download DriverAGENT

    Option 2

    View more detailed information about this driver prior to downloading to your PC.


    View Driver Details
    ; /****************************************************************************
    ; * Copyright 2006 Netgear Communications Inc., all rights reserved.                                              
    ; * INF file for Netgear reference designs                                                                                          
    ; ****************************************************************************/
    
    [version]
    	Signature	= "$Windows NT$"		; Combined Win9x/Win2k inf
    	Class=Net
    	ClassGUID	= {4d36e972-e325-11ce-bfc1-08002be10318}
    	Provider	= %NETGEAR%
    	Compatible	= 1
            DriverVer=12/19/2006, 4.102.15.61
    	CatalogFile	=wn311b.cat
                    CatalogFile.NTamd64=wn311b64.cat
    ; for WinVista, replace NTamd64 with NTx86.6.0, NTamd64.6.0
    [Manufacturer]
    	%NETGEAR% = NETGEAR, NTx86.6.0, NTamd64.6.0
    
    [ControlFlags] 
    	ExcludeFromSelect = *
    
    ;-----------------------------------------------------------------
    ; x64 (AMD64, Intel EM64T) - WinVista
    ;
    [NETGEAR.NTamd64.6.0]
    
    	%NETGEAR_DeviceDesc% = NETG_DEV_0013.ndi, PCI\VEN_14E4&DEV_4329&SUBSYS_7D001385
    
    ;-----------------------------------------------------------------
    ; x86 - WinVista
    ;
    [NETGEAR.NTx86.6.0]
    
    	%NETGEAR_DeviceDesc% = NETG_DEV_0013.ndi, PCI\VEN_14E4&DEV_4329&SUBSYS_7D001385
    
    ;-----------------------------------------------------------------
    [NETG_DEV_0013.ndi.NTamd64]
    	*IfType		= 71    ; IF_TYPE_IEEE80211
    	*MediaType	= 16    ; NdisMediumNative802_11
    	*PhysicalMediaType = 9  ; NdisPhysicalMediumNative802_11
    	Characteristics	= 0x84	; NCF_PHYSICAL | NCF_HAS_UI
    	BusType		= 5			; PCI bus
    	AddReg		= Netgear.reg, Netgear.brcm.reg, common.reg, gn.options.reg
    	DelReg          = common.delreg, common.vista.delreg, rate.delreg
    	CopyFiles	= NETGEAR_NT60.files.NTamd64
    
    [NETG_DEV_0013.ndi.NTamd64.Services]
    	AddService = NETGEAR, 2, NETGEAR_NT60.Service.NTamd64, common.EventLog
    
    [NETG_DEV_0013.ndi.NTx86]
    	*IfType		= 71    ; IF_TYPE_IEEE80211
    	*MediaType	= 16    ; NdisMediumNative802_11
    	*PhysicalMediaType = 9  ; NdisPhysicalMediumNative802_11
    	Characteristics	= 0x84	; NCF_PHYSICAL | NCF_HAS_UI
    	BusType		= 5			; PCI bus
    	AddReg		= Netgear.reg, Netgear.brcm.reg, common.reg, gn.options.reg
    	DelReg          = common.delreg, common.vista.delreg, rate.delreg
    	CopyFiles	= NETGEAR_NT60.files.NTx86
    
    
    [NETG_DEV_0013.ndi.NTx86.Services]
    	AddService = NETGEAR, 2, NETGEAR_NT60.Service.NTx86, common.EventLog
    
    ; NT systems
    ;
    [Netgear.reg]
    	; Ndis Info
    	; Interfaces
    	HKR,	Ndi\Interfaces,	UpperRange,	,	"ndis5"
    	HKR,	Ndi\Interfaces,	LowerRange,	,	"ethernet,wlan"
    
    [Netgear.brcm.reg]
    	HKR,	Ndi,	HelpText,		,	%NETGEAR_HELP%
    	HKR,	Ndi,	Service,		0,	"NETGEAR"
    
    [common.EventLog]
    	AddReg = common.AddEventLog.reg
    
    [common.AddEventLog.reg]
    	HKR,	,	EventMessageFile,	0x00020000,	"%%SystemRoot%%\System32\netevent.dll"
    	HKR,	,	TypesSupported,		0x00010001,	7
    
    
    ; service-install-section
    ;
    [NETGEAR_NT60.Service.NTamd64]
    	DisplayName	= %NETGEAR_Service_DispName%
    	ServiceType	= 1			; %SERVICE_KERNEL_DRIVER%
    	StartType	= 3			; %SERVICE_DEMAND_START%
    	ErrorControl	= 1			; %SERVICE_ERROR_NORMAL%
    	ServiceBinary	= %12%\wn311b64.sys
    	LoadOrderGroup	= NDIS
    
    [NETGEAR_NT60.Service.NTx86]
    	DisplayName	= %NETGEAR_Service_DispName%
    	ServiceType	= 1			; %SERVICE_KERNEL_DRIVER%
    	StartType	= 3			; %SERVICE_DEMAND_START%
    	ErrorControl	= 1			; %SERVICE_ERROR_NORMAL%
    	ServiceBinary	= %12%\wn311b.sys
    	LoadOrderGroup	= NDIS
    
    
    ; filename for CopyFiles
    ;
    ; Flag = 2 is COPYFLG_NOSKIP (2)
    ; Flag = 33 is COPYFLG_WARN_IF_SKIP (1) | COPYFLG_NO_VERSION_DIALOG (32)
    [NETGEAR_NT60.files.NTamd64]
    	wn311b64.SYS,,,6
    
    [NETGEAR_NT60.files.NTx86]
    	WN311B.SYS,,,6
    
    ; common for WinVista, but excluded in WinXP and older
    [common.vista.delreg]
    	HKR, Ndi\params\vlan_mode
    	HKR,,vlan_mode
    	HKR, Ndi\params\PowerSaveMode
    
    ; common for all platform
    [common.delreg]
    	HKR,,"gpiotimerval"
    	HKR,,"gpio3"
    	HKR,,"gpio2"
    	HKR,,"gpio1"
    	HKR,,"gpio0"
    	HKR, Ndi\params\RoamPref
            HKR, Ndi\params\AssocPref
    	HKR, Ndi\params\Locale
    	HKR,,Locale
    	HKR, Ndi\params\RoamTrigger
    	HKR, Ndi\params\WME
    	HKR, Ndi\params\MixedCell
    	HKR, Ndi\params\Channel
    	HKR,,Channel
    	HKR, Ndi\params\IBSSGMode
    	HKR,,IBSSGMode
    	       		       
    [rate.delreg]
    	HKR,	Ndi\params\Rate
    	HKR,	Ndi\params\RateA
    
    ; common for WinVista, but excluded in WinXP and older
    
    
    ; common for WinXP and older, but excluded in WinVista
    
    
    ; common for all platform
    [common.reg]
    	HKR, ,"EnableSoftAP", 0, "0"
    	HKR, ,"EnableAutoConnect", 0, "0"
    	HKR,	Ndi\params\Country, ParamDesc,	0,	%Location%
    	HKR,	Ndi\params\Country, type,		0,	"enum"
    
    	HKR,	Ndi\params\Country\enum, "AU",	0,	%Australia%
    	HKR,	Ndi\params\Country\enum, "BR",	0,	%Brazil%
    	HKR,	Ndi\params\Country\enum, "CA",	0,	%Canada%
    	HKR,	Ndi\params\Country\enum, "CN",	0,	%China%
    	HKR,	Ndi\params\Country\enum, "FR",	0,	%France%
    	HKR,	Ndi\params\Country\enum, "IL",	0,	%Israel%
    	HKR,	Ndi\params\Country\enum, "JP",	0,	%Japan%
    	HKR,	Ndi\params\Country\enum, "MX",	0,	%Mexico%
    	HKR,	Ndi\params\Country\enum, "ZA",	0,	%SouthAfrica%
    	HKR,	Ndi\params\Country\enum, "GB",	0,	%UnitedKingdom%
    	HKR,	Ndi\params\Country\enum, "US",	0,	%UnitedStates%
    ;	HKR,	Ndi\params\Country\enum, "",	0,	%Default%
    	HKR,	Ndi\params\Country,	default,, 	"US"
    
    
    	HKR,	Ndi\params\RadioState, ParamDesc,	0,	%RadioEnableDisable%
    	HKR,	Ndi\params\RadioState, type,		0,	"enum"
    	HKR,	Ndi\params\RadioState\enum, "1",		0,	%Disabled%
    	HKR,	Ndi\params\RadioState\enum, "0",		0,	%Enabled%
    	HKR,    Ndi\params\RadioState,default,,"0"	
    
    	HKR,	Ndi\params\PwrOut, ParamDesc,	0,	%PowerOutput%
    	HKR,	Ndi\params\PwrOut, type,		0,	"enum"
    	HKR,	Ndi\params\PwrOut\enum, "100",	0,	"100%"
    	HKR,	Ndi\params\PwrOut\enum, "75",	0,	"75%"
    	HKR,	Ndi\params\PwrOut\enum, "50",	0,	"50%"
    	HKR,	Ndi\params\PwrOut\enum, "25",	0,	"25%"
            HKR,	Ndi\params\PwrOut\enum, "12",	0,	"12.5%"
            HKR,	Ndi\params\PwrOut\enum, "5",	0,	"Lowest"	
            HKR,	Ndi\params\PwrOut,default,,"100"
    
    	HKR,					,"mimo_antsel",	0,	"0"
            HKR,					,"FrameBursting",	0,	"1"
            HKR,					,"LanExpress",	0,	"BR00"
    	HKR,					,"WEP",	0,	""
    	HKR,					,"NetworkType",	0,	"-1"
    	HKR,					,"SSID",	0,	""
    
    	HKR,					,"ledbh0",	0,	"10"
    	HKR,					,"ledbh1",	0,	"-1"
    	HKR,					,"ledbh2",	0,	"-1"
    	HKR,					,"ledbh3",	0,	"-1"
    	HKR,					,"ledblinkslow",	0,	"-1"
    	HKR,					,"ledblinkmed",	0,	"-1"
    	HKR,					,"ledblinkfast",	0,	"-1"
    	HKR,					,"leddc",	0,	"0"
    
    	HKR,					,"scan_channel_time",	0,	"-1"
    	HKR,					,"scan_unassoc_time",	0,	"-1"
    	HKR,					,"scan_home_time",		0,	"-1"
    	HKR,					,"scan_passes",			0,	"-1"
    
    	HKR,					,"BadFramePreempt",		0,	"0"
    
    	HKR,					,"Interference_Mode",		0,	"3"
    
    	HKR,					,"ccx_rm",			0,	"1"
    	HKR,					,"ccx_rm_limit",		0,	"300"
    
    	HKR,					,"EFCEnable",		0,	"0"
    
    
                  HKR,					,"Afterburner",	0,	"0"
                 HKR,					,"antdiv",	0,	"-1"
     HKR,					,"ApCompatMode",	0,	"0"
     HKR,					,"BTCoexist",	0,	"0"
     HKR,					,"Chanspec",	0,	"11"
     HKR,					,"frag",	0,	"2346"
     HKR,					,"IBSSAllowed",	0,	"1"
     HKR,					,"IBSSGMode",	0,	"0"
     HKR,					,"IBSSGProtection",	0,	"2"
     HKR,					,"IBSSLink",	0,	"1"
     HKR,					,"LOM",	0,	"0"
     HKR,					,"Managed",	0,	"1"
     HKR,					,"MixedCell",	0,	"0"
     HKR,					,"MPC",	0,	"1"
     HKR,					,"Rate",	0,	"0"
     HKR,					,"RoamDelta",	0,	"1"
     HKR,					,"rts",	0,	"2347"
     HKR,					,"ssid_auto_promote",	0,	"0"
     HKR,					,"vlan_mode",	0,	"-1"
     HKR,					,"WZCCoexist",	0,	"0"
     HKR,					,"RoamTrigger",	0,	"0"
    
    ; the next line forces upgrade installation to configure WME value to be -1 
      HKR,	                                ,"WME",0,"-1"
    
    
    [gn.options.reg]
    
    
    	HKR,	Ndi\params\PLCPHeader, ParamDesc,	0,	%BSSPLCPHeader%
    	HKR,	Ndi\params\PLCPHeader, type,		0,	"enum"
    	HKR,	Ndi\params\PLCPHeader\enum, "-1",	0,	%Long%
    	HKR,	Ndi\params\PLCPHeader\enum, "0",	0,	%AutoShortLong%
    	HKR,	Ndi\params\PLCPHeader,default,,"0"
    
    ; options common to both b and g
    
    [DestinationDirs]
    	DefaultDestDir=11
    	NETGEAR_NT60.files.NTx86 = 12
                     NETGEAR_NT60.files.NTamd64 = 12
    
    [SourceDisksNames]
    	1=%NETGEAR_DiskName%,,
    
    [SourceDisksFiles.amd64]
    	wn311b64.sys=1
    
    ; for WinVista specify WN311B.SYS
    [SourceDisksFiles.x86]
    	wn311b.sys=1
    
    ; for WinVista specify WN311B.SYS
    [SourceDisksFiles]
    	wn311b.sys=1
    
    [strings]
    NETGEAR="Netgear Communications Inc."
    NETGEAR_HELP="The Netgear 802.11 Network Adapter provides wireless local area networking."
    NETGEAR_Service_DispName="Netgear 802.11 Network Adapter Driver"
    NETGEAR_DiskName="802.11 Network Adapter Install Disk"
    NETGEAR_DeviceDesc="RangeMax(tm) NEXT Wireless Adapter WN311B"
    Auto="Auto"
    AutoShortLong="Auto (Short/Long)"
    BSSPLCPHeader="802.11b preamble"  
    Default="Default"
    Disable="Disable"
    Disabled="Disabled"
    Enable="Enable"
    Enabled="Enabled"
    Long="Long"
    PLCPHeader="PLCP Header"
    PowerOutput="Transmit Power"     
    PowerSaveMode="Power Save Mode"
    RadioEnableDisable="Radio On/Off"   
    Rate="Rate"
    Location="Regional Domain"  
    Fast="Fast"
    WME="WMM"
    Afterburner="Afterburner"
    IbssAllowed="IBSS Allowed"
    MixedCell="Mixed Cell Support"
    vlan_mode="VLAN Priority Support"
    VLANEnabled="VLAN Enabled"
    UnitedStates = "United States"
    SouthAfrica = "Africa"
    Australia = "Australia"
    China = "Asia"
    Canada= "Canada"
    UnitedKingdom= "Europe"
    France	= "France"
    Israel= "Israel"
    Mexico	= "Mexico"
    Japan= "Japan"
    Brazil = "Sourth America"