PageRenderTime 82ms CodeModel.GetById 41ms app.highlight 3ms RepoModel.GetById 37ms app.codeStats 0ms

/plugins/geshi/actions.php

http://0byte.googlecode.com/
PHP | 35 lines | 31 code | 4 blank | 0 comment | 6 complexity | 5a479d97c34927f63b036fe1799b67eb MD5 | raw file
 1<?php
 2
 3$txt = str_replace("[code]", '[code=]', $txt);
 4preg_match_all('/\[code([^\]]*?)\]/is',$txt, $lang);
 5$arr = preg_split("/\[(.?)code(.*?)\]/",$txt);
 6$q = 1;
 7$txt = "";
 8$replace = array('<br />' => "\n", '&lt;' => '<', '&gt;' => '>', '&#39;' => "'", '&#34;' => '"','&amp;'=>'&');
 9foreach ($arr as $i) {
10    
11    if ($q % 2 == 0) {
12      
13        require_once 'lib/geshi/geshi.php';
14        $i = str_replace(array_keys($replace), array_values($replace), $i);
15        $lang[$q / 2 - 1] = preg_replace('/\[code\=(.*?)\]/is', "$1", $lang[$q / 2 - 1]);
16        $i = geshi_highlight($i, $lang[0][$q / 2 - 1], null, true);
17        $i = str_replace(array('[code', '[/code]'), '', $i);
18        $cnt = substr_count($i, "<br />");
19        $ln = "";
20        if ($cnt != 0) {
21            for ($e = 2; $e <= ($cnt+1); $e++) {
22                $ln .= $e . "<br />";
23            }
24            $i = render_util('code_lines', array('lang' => $lang[0][$q / 2 - 1], 'code' => $i, 'lines' => $ln));
25        } else {
26            $i = render_util('code_utils', array('lang' => $lang[0][$q / 2 - 1], 'code' => $i));
27        }
28    }
29    $txt .= $i;
30    $q++;
31}
32
33$txt = str_replace("<a href", "<a rel='nofollow' href", $txt);
34$text=$txt;
35?>