Zeile 27 | Zeile 27 |
---|
/** * Internal cache of MyCode. *
|
/** * Internal cache of MyCode. *
|
| * @access public
|
* @var mixed */ public $mycode_cache = 0;
| * @var mixed */ public $mycode_cache = 0;
|
Zeile 34 | Zeile 35 |
---|
/** * Internal cache of smilies *
|
/** * Internal cache of smilies *
|
| * @access public
|
* @var mixed */ public $smilies_cache = 0;
| * @var mixed */ public $smilies_cache = 0;
|
Zeile 41 | Zeile 43 |
---|
/** * Internal cache of badwords filters *
|
/** * Internal cache of badwords filters *
|
| * @access public
|
* @var mixed */ public $badwords_cache = 0;
| * @var mixed */ public $badwords_cache = 0;
|
Zeile 48 | Zeile 51 |
---|
/** * Base URL for smilies *
|
/** * Base URL for smilies *
|
| * @access public
|
* @var string */ public $base_url;
| * @var string */ public $base_url;
|
Zeile 55 | Zeile 59 |
---|
/** * Parsed Highlights cache *
|
/** * Parsed Highlights cache *
|
* @access private
| * @access public
|
* @var array */
|
* @var array */
|
var $highlight_cache = array();
| public $highlight_cache = array();
|
/** * Options for this parsed message (Private - set by parse_message argument) *
|
/** * Options for this parsed message (Private - set by parse_message argument) *
|
* @access private
| * @access public
|
* @var array */
|
* @var array */
|
private $options;
| public $options;
|
/** * Parses a message with the specified options.
| /** * Parses a message with the specified options.
|
Zeile 167 | Zeile 171 |
---|
if(count($code_matches) > 0) { foreach($code_matches as $text)
|
if(count($code_matches) > 0) { foreach($code_matches as $text)
|
{
| {
|
// Fix up HTML inside the code tags so it is clean if($options['allow_html'] != 0) {
| // Fix up HTML inside the code tags so it is clean if($options['allow_html'] != 0) {
|
Zeile 333 | Zeile 337 |
---|
// Parse quotes first $message = $this->mycode_parse_quotes($message);
|
// Parse quotes first $message = $this->mycode_parse_quotes($message);
|
|
|
$message = $this->mycode_auto_url($message);
$message = str_replace('$', '$', $message); // Replace the rest $message = preg_replace($this->mycode_cache['standard']['find'], $this->mycode_cache['standard']['replacement'], $message);
|
$message = $this->mycode_auto_url($message);
$message = str_replace('$', '$', $message); // Replace the rest $message = preg_replace($this->mycode_cache['standard']['find'], $this->mycode_cache['standard']['replacement'], $message);
|
|
|
// Replace the nestable mycode's foreach($this->mycode_cache['nestable'] as $mycode) {
| // Replace the nestable mycode's foreach($this->mycode_cache['nestable'] as $mycode) {
|
Zeile 354 | Zeile 358 |
---|
while(preg_match("#\[list\](.*?)\[/list\]#esi", $message)) { $message = preg_replace("#\s?\[list\](.*?)\[/list\](\r\n?|\n?)#esi", "\$this->mycode_parse_list('$1')\n", $message);
|
while(preg_match("#\[list\](.*?)\[/list\]#esi", $message)) { $message = preg_replace("#\s?\[list\](.*?)\[/list\](\r\n?|\n?)#esi", "\$this->mycode_parse_list('$1')\n", $message);
|
}
| }
|
// Replace lists. while(preg_match("#\[list=(a|A|i|I|1)\](.*?)\[/list\](\r\n?|\n?)#esi", $message)) { $message = preg_replace("#\s?\[list=(a|A|i|I|1)\](.*?)\[/list\]#esi", "\$this->mycode_parse_list('$2', '$1')\n", $message);
|
// Replace lists. while(preg_match("#\[list=(a|A|i|I|1)\](.*?)\[/list\](\r\n?|\n?)#esi", $message)) { $message = preg_replace("#\s?\[list=(a|A|i|I|1)\](.*?)\[/list\]#esi", "\$this->mycode_parse_list('$2', '$1')\n", $message);
|
}
| }
|
// Convert images when allowed. if($options['allow_imgcode'] != 0) {
| // Convert images when allowed. if($options['allow_imgcode'] != 0) {
|
Zeile 389 | Zeile 393 |
---|
{ global $cache; $this->smilies_cache = array();
|
{ global $cache; $this->smilies_cache = array();
|
|
|
$smilies = $cache->read("smilies"); if(is_array($smilies)) { foreach($smilies as $sid => $smilie) {
|
$smilies = $cache->read("smilies"); if(is_array($smilies)) { foreach($smilies as $sid => $smilie) {
|
$this->smilies_cache[$smilie['find']] = "<img src=\"{$this->base_url}{$smilie['image']}\" style=\"vertical-align: middle;\" border=\"0\" alt=\"{$smilie['name']}\" title=\"{$smilie['name']}\" />";
| $this->smilies_cache[$smilie['find']] = "<img src=\"{$smilie['image']}\" style=\"vertical-align: middle;\" border=\"0\" alt=\"{$smilie['name']}\" title=\"{$smilie['name']}\" />";
|
} } }
| } } }
|
Zeile 416 | Zeile 420 |
---|
} $message = ' ' . $message . ' ';
|
} $message = ' ' . $message . ' ';
|
|
|
// First we take out any of the tags we don't want parsed between (url= etc) preg_match_all("#\[(url(=[^\]]*])?\](.*?)\[\/url\]|quote=([^\]]*)?\])#i", $message, $bad_matches, PREG_PATTERN_ORDER); $message = preg_replace("#\[(url(=[^\]]*])?\](.*?)\[\/url\]|quote=([^\]]*)?\])#si", "<mybb-bad-sm>", $message);
| // First we take out any of the tags we don't want parsed between (url= etc) preg_match_all("#\[(url(=[^\]]*])?\](.*?)\[\/url\]|quote=([^\]]*)?\])#i", $message, $bad_matches, PREG_PATTERN_ORDER); $message = preg_replace("#\[(url(=[^\]]*])?\](.*?)\[\/url\]|quote=([^\]]*)?\])#si", "<mybb-bad-sm>", $message);
|
Zeile 437 | Zeile 441 |
---|
if(substr($find, 0, 1) == ";") { $find = "(?<!>|<|&)".$find;
|
if(substr($find, 0, 1) == ";") { $find = "(?<!>|<|&)".$find;
|
}
| }
|
$message = @preg_replace("#(?<=[^\"])".$find."(?=.\W|\"|\W.|\W$)#si", $replace, $message, $remaining, $replacements);
|
$message = @preg_replace("#(?<=[^\"])".$find."(?=.\W|\"|\W.|\W$)#si", $replace, $message, $remaining, $replacements);
|
|
|
if($message == null) { $message = preg_replace("#(?<=[^&;\"])".$orig_find."(?=.\W|\"|\W.|\W$)#si", $replace, $orig_message, $remaining);
|
if($message == null) { $message = preg_replace("#(?<=[^&;\"])".$orig_find."(?=.\W|\"|\W.|\W$)#si", $replace, $orig_message, $remaining);
|
}
| }
|
$remaining -= $replacements; if($remaining <= 0) {
| $remaining -= $replacements; if($remaining <= 0) {
|
Zeile 459 | Zeile 463 |
---|
if(count($bad_matches[0]) > 0) { foreach($bad_matches[0] as $match)
|
if(count($bad_matches[0]) > 0) { foreach($bad_matches[0] as $match)
|
{
| {
|
$match = str_replace('$', '\$', $match); $message = preg_replace("#<mybb-bad-sm>#", $match, $message, 1); } }
return trim($message);
|
$match = str_replace('$', '\$', $match); $message = preg_replace("#<mybb-bad-sm>#", $match, $message, 1); } }
return trim($message);
|
}
| }
|
/** * Generates a cache of badwords filters.
| /** * Generates a cache of badwords filters.
|
Zeile 502 | Zeile 506 |
---|
{ $badword['replacement'] = "*****"; }
|
{ $badword['replacement'] = "*****"; }
|
$badword['badword'] = str_replace('\*', '(.*)',preg_quote($badword['badword'], "#")); $message = preg_replace("#(^|\s|\W)".$badword['badword']."(\W|\s|$)#i", "\\1".$badword['replacement']."\\2", $message);
| // Take into account the position offset for our last replacement. $index = substr_count($badword['badword'], '*')+2; $badword['badword'] = str_replace('\*', '([a-zA-Z0-9_]{1})', preg_quote($badword['badword'], "#")); // Ensure we run the replacement enough times but not recursively (i.e. not while(preg_match..)) $count = preg_match_all("#(^|\W)".$badword['badword']."(\W|$)#i", $message, $matches); for($i=0; $i < $count; ++$i) { $message = preg_replace("#(^|\W)".$badword['badword']."(\W|$)#i", "\\1".$badword['replacement'].'\\'.$index, $message); }
|
} } if($options['strip_tags'] == 1)
| } } if($options['strip_tags'] == 1)
|
Zeile 1008 | Zeile 1021 |
---|
function mycode_auto_url($message) { $message = " ".$message;
|
function mycode_auto_url($message) { $message = " ".$message;
|
$message = preg_replace("#([\>\s\(\)])(http|ftp|news){1}://([^\/\"\s\<\[\.]+\.([^\/\"\s\<\[\.]+\.)*[\w]+(:[0-9]+)?(/[^\"\s<\[]*)?)#i", "$1[url]$2://$3[/url]", $message);
| $message = preg_replace("#([\>\s\(\)])(http|https|ftp|news){1}://([^\/\"\s\<\[\.]+\.([^\/\"\s\<\[\.]+\.)*[\w]+(:[0-9]+)?(/[^\"\s<\[]*)?)#i", "$1[url]$2://$3[/url]", $message);
|
$message = preg_replace("#([\>\s\(\)])(www|ftp)\.(([^\/\"\s\<\[\.]+\.)*[\w]+(:[0-9]+)?(/[^\"\s<\[]*)?)#i", "$1[url]$2.$3[/url]", $message); $message = my_substr($message, 1);
| $message = preg_replace("#([\>\s\(\)])(www|ftp)\.(([^\/\"\s\<\[\.]+\.)*[\w]+(:[0-9]+)?(/[^\"\s<\[]*)?)#i", "$1[url]$2.$3[/url]", $message); $message = my_substr($message, 1);
|