([\r\n])/","$1",$var); } } class NP_HighlightSource extends NucleusPlugin { function getName() { return 'HighlightSource'; } function getAuthor() { return 'nakahara21'; } function getURL() { return 'http://xx.nakahara21.net'; } function getVersion() { return '0.8'; } function getDescription() { return 'HighlightSource'; } function supportsFeature($what) { switch($what){ case 'SqlTablePrefix': return 1; default: return 0; } } function install() { $this->createOption("Li", "Show line number?", "yesno", "no"); } function getEventList() { return array('PreItem'); } function event_PreItem($data){ $this->currentItem = &$data["item"]; $this->currentItem->more = preg_replace("/(<\/hs>)
\r\n/","$1",$this->currentItem->more); $this->currentItem->body = preg_replace_callback('#(.*?)<\/hs>#s', array(&$this, 'phpHighlight'), $this->currentItem->body); $this->currentItem->more = preg_replace_callback('#(.*?)<\/hs>#s', array(&$this, 'phpHighlight'), $this->currentItem->more); } function phpHighlight($matches){ ini_set('highlight.string', '#CC0000'); //#CC0000 default ini_set('highlight.comment', '#FF9900'); //#FF9900 default ini_set('highlight.keyword', '#006600'); //#006600 default ini_set('highlight.bg', '#dddddd'); //#dddddd default ini_set('highlight.default', '#0000CC'); //#0000CC default ini_set('highlight.html', '#000000'); //#000000 default $code = trim(removeBreaks($matches[1]), "\r,\n"); if(substr(trim($code),0,2) != ""){ $code = $code."\n?>"; $eflag = 1; } // $code = stripslashes($code); $code = highlight_string($code, true); $source = explode('
', $code); for($i=0;$i"; $source[$i] = preg_replace("/<\/font>/s"," ",$source[$i]); $ppp = preg_match_all("//s",$precode,$pmat,PREG_SET_ORDER); if($pmat){ $las = count($pmat) - 1; $pcolor = $pmat[$las][1]; } $precolor = ''; } $code = @join("
\n", $source) ; if($sflag) $code = ereg_replace("()([\r\n])()<\?php
\n
", '\\1', $code); else $code = ereg_replace("()([\r\n])", '\\1', $code); if($eflag) $code = ereg_replace("
\n
\?>\n
\n", "
", $code); else $code = ereg_replace("
\n\n", "", $code); if($this->getOption('Li') == 'no') return '
'.$code.'
'; $code = explode('', $code); $source = explode('
', $code[1]); for($i=0;$i'; } $text = '
'; $text .= $code[0]; $text .= "
    ". @join('', $source) . "\n
"; $text .= $code[2]; $text .= '
'; return $text; } } ?>