Code: Alles auswählen
#
#-----[ COPY ]------------------------------------------
# codetemp.txt is an empty file that is used for writing and reading.
Codenum/*.* TO Codenum/*.*
#
#-----[ OPEN ]------------------------------------------
#
includes/bbcode.php
#
#-----[ FIND ]------------------------------------------
#
function bbencode_second_pass_code($text, $uid, $bbcode_tpl)
{
global $lang;
$code_start_html = $bbcode_tpl['code_open'];
$code_end_html = $bbcode_tpl['code_close'];
// First, do all the 1st-level matches. These need an htmlspecialchars() run,
// so they have to be handled differently.
$match_count = preg_match_all("#\[code:1:$uid\](.*?)\[/code:1:$uid\]#si", $text, $matches);
for ($i = 0; $i < $match_count; $i++)
{
$before_replace = $matches[1][$i];
$after_replace = $matches[1][$i];
// Replace 2 spaces with " " so non-tabbed code indents without making huge long lines.
$after_replace = str_replace(" ", " ", $after_replace);
// now Replace 2 spaces with " " to catch odd #s of spaces.
$after_replace = str_replace(" ", " ", $after_replace);
// Replace tabs with " " so tabbed code indents sorta right without making huge long lines.
$after_replace = str_replace("\t", " ", $after_replace);
// now Replace space occurring at the beginning of a line
$after_replace = preg_replace("/^ {1}/m", ' ', $after_replace);
$str_to_match = "[code:1:$uid]" . $before_replace . "[/code:1:$uid]";
$replacement = $code_start_html;
$replacement .= $after_replace;
$replacement .= $code_end_html;
$text = str_replace($str_to_match, $replacement, $text);
}
// Now, do all the non-first-level matches. These are simple.
$text = str_replace("[code:$uid]", $code_start_html, $text);
$text = str_replace("[/code:$uid]", $code_end_html, $text);
return $text;
} // bbencode_second_pass_code()
#
#-----[ REPLACE, WITH ]------------------------------------------
#
function bbencode_second_pass_code($text, $uid, $bbcode_tpl)
{
global $lang;
// First, do all the 1st-level matches. These need an htmlspecialchars() run,
// so they have to be handled differently.
$match_count = preg_match_all("#\[code:1:$uid\](.*?)\[/code:1:$uid\]#si", $text, $matches);
$code_start_html = $bbcode_tpl['code_open'];
$code_end_html = $bbcode_tpl['code_close'];
for ($i = 0; $i < $match_count; $i++)
{
$tdnumbers = "";
$before_replace = $matches[1][$i];
$after_replace = $matches[1][$i];
$codetemp = fopen('Codenum/codetemp.txt', 'w');
fwrite($codetemp, $before_replace);
fclose($codetemp);
$tempfile = file('Codenum/codetemp.txt');
foreach ($tempfile as $line_num => $line) {
// Replace 2 spaces with " " so non-tabbed code indents without making huge long lines.
$line = str_replace(" ", " ", $line);
// now Replace 2 spaces with " " to catch odd #s of spaces.
$line = str_replace(" ", " ", $line);
// Replace tabs with " " so tabbed code indents sorta right without making huge long lines.
$line = str_replace("\t", " ", $line);
// now Replace space occurring at the beginning of a line
$line = preg_replace("/^ {1}/m", ' ', $line);
if ($line_num > 0){
$tdnumbers = $tdnumbers. '<tr><td width="36" background="Codenum/codenum.png?number='.$line_num.'" valign="top"><span class="gensmall"></span></td> <td valign="top" style="border-left:1px dotted gray;"><span class="gensmall">' . $line . "</span></td></tr>";
$tdlines = $tdlines . $line . '<br >';
}
}
$str_to_match = "[code:1:$uid]" . $before_replace . "[/code:1:$uid]";
$replacement = $code_start_html;
$replacement .= '<table cellpadding="0" cellspacing="0" border="0">'.$tdnumbers.'</table>';
$replacement .= $code_end_html;
$text = str_replace($str_to_match, $replacement, $text);
}
return $text;
} // bbencode_second_pass_code()
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/bbcode.tpl
#
#-----[ FIND ]------------------------------------------
#
<!-- BEGIN code_open --></span>
<table width="90%" cellspacing="1" cellpadding="3" border="0" align="center">
<tr>
<td><span class="genmed"><b>{L_CODE}:</b></span></td>
</tr>
<tr>
<td class="code"><!-- END code_open -->
#
#-----[ REPLACE, WITH ]------------------------------------------
#
<!-- BEGIN code_open --></span>
<table width="90%" cellspacing="2" cellpadding="0" border="0" align="center">
<tr>
<td colspan="2"><span class="genmed"><b>{L_CODE}:</b></span></td>
</tr>
<tr>
<td class="code" valign="top"><!-- END code_open -->
#
#-----[ CHMOD ]------------------------------------------
chmod Codenum/codetemp.txt to 666
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
siehe >>> http://oconner.de/webmaster-hilfe.org/v ... highlight=