News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Sources/Subs.php have been messed up with BBCode

Started by Martinike, February 08, 2010, 11:41:04 AM

Previous topic - Next topic

Martinike


Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/a9991594/public_html/forum/Sources/Subs.php on line 1479

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/a9991594/public_html/forum/Sources/Subs.php on line 1486


BBCode is: http://www.simplemachines.org/community/index.php?topic=206277.0

I did it all, but error's showing.

          array(
            'tag' => 'pawn',
            'type' => 'unparsed_content',
            'content' => '<div class="codeheader">' . $txt['pawn'] . ':</div><div class="code">' . ($context['browser']['is_gecko'] ? '<pre style="margin-top: 0; display: inline;">$1</pre>' : '$1') . '</div>',
            'validate' => create_function('&$tag, &$data, $disabled', '
                global $context;

               if (!isset($disabled[\'pawn\']))
               {

               $data = str_replace(
               array(
                  \'public\',
                  \'return\',
                  \'sizeof\',
                  \'switch\',
                  \'true\',
                  \'false\',
                  \'if\',
                  \'new\',
                  \'else\',
                  \'for(\',
                  \'while\',
                  \'(\',
                  \')\',
                  \'[\',
                  \']\',
                  \'{\',
                  \'}\'
               ),
               array(
                  \'<span style="color: blue;">public</span>\',
                  \'<span style="color: blue;">return</span>\',
                  \'<span style="color: blue;">sizeof</span>\',
                  \'<span style="color: blue;">switch</span>\',
                  \'<span style="color: blue;">true</span>\',
                  \'<span style="color: blue;">false</span>\',
                  \'<span style="color: blue;">if</span>\',
                  \'<span style="color: blue;">new</span>\',
                  \'<span style="color: blue;">else</span>\',
                  \'<span style="color: blue;">for</span>(\',
                  \'<span style="color: blue;">while</span>\',
                  \'<span style="color: red;">(</span>\',
                  \'<span style="color: red;">)</span>\',
                  \'<span style="color: red;">[</span>\',
                  \'<span style="color: red;">]</span>\',
                  \'<span style="color: red;">{</span>\',
                  \'<span style="color: red;">}</span>\',
                  \'|||\'
               ), $data);

                $data = preg_replace(
                  array(
                     \'~#(.+?)\<br \/>~is\',
                     \'~\/\/(.+?)\<br \/\>~i\',
                     \'~\/\*(.+?)\*\/~i\'
                  ),
                  array(
                     \'<span style="color: blue;">#$1<br /></span>\',
                     \'<span style="color: green;">//$1<br /></span>\',
                     \'<span style="color: green;">/*$1*/</span>\'
                   ), $data);
                   $data = str_replace(\'|||\', \''\', $data);

                  // Older browsers are annoying, aren\'t they?
                  if ($context[\'browser\'][\'is_ie4\'] || $context[\'browser\'][\'is_ie5\'] || $context[\'browser\'][\'is_ie5.5\'])
                     $data = str_replace("\t", "<pre style=\"display: inline;\">\t</pre>", $data);
                  elseif (!$context[\'browser\'][\'is_gecko\'])
                     $data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data);
               }'),
            'block_level' => true,
         ),

Matthew K.

Try this:               array(
                    'tag' => 'pawn',
            'type' => 'unparsed_content',
            'content' => '<div class="codeheader">' . $txt['pawn'] . ':</div><div class="code">' . ($context['browser']['is_gecko'] ? '<pre style="margin-top: 0; display: inline;">$1</pre>' : '$1') . '</div>',
            'validate' => create_function('&$tag, &$data, $disabled', '
                global $context;

               if (!isset($disabled[\'pawn\']))
               {

               $data = str_replace(
               array(
                  \'public\',
                  \'return\',
                  \'sizeof\',
                  \'switch\',
                  \'true\',
                  \'false\',
                  \'if\',
                  \'new\',
                  \'else\',
                  \'for(\',
                  \'while\',
                  \'(\',
                  \')\',
                  \'[\',
                  \']\',
                  \'{\',
                  \'}\'
               ),
               array(
                  \'<span style="color: blue;">public</span>\',
                  \'<span style="color: blue;">return</span>\',
                  \'<span style="color: blue;">sizeof</span>\',
                  \'<span style="color: blue;">switch</span>\',
                  \'<span style="color: blue;">true</span>\',
                  \'<span style="color: blue;">false</span>\',
                  \'<span style="color: blue;">if</span>\',
                  \'<span style="color: blue;">new</span>\',
                  \'<span style="color: blue;">else</span>\',
                  \'<span style="color: blue;">for</span>\',
                  \'<span style="color: blue;">while</span>\',
                  \'<span style="color: red;">(</span>\',
                  \'<span style="color: red;">)</span>\',
                  \'<span style="color: red;">[</span>\',
                  \'<span style="color: red;">]</span>\',
                  \'<span style="color: red;">{</span>\',
                  \'<span style="color: red;">}</span>\',
                  \'|||\'
               ), $data);

                $data = preg_replace(
                  array(
                     \'~#(.+?)\<br \/>~is\',
                     \'~\/\/(.+?)\<br \/\>~i\',
                     \'~\/\*(.+?)\*\/~i\'
                  ),
                  array(
                     \'<span style="color: blue;">#$1<br /></span>\',
                     \'<span style="color: green;">//$1<br /></span>\',
                     \'<span style="color: green;">/*$1*/</span>\'
                   ), $data);
                   $data = str_replace(\'|||\', \''\', $data);

                  // Older browsers are annoying, aren\'t they?
                  if ($context[\'browser\'][\'is_ie4\'] || $context[\'browser\'][\'is_ie5\'] || $context[\'browser\'][\'is_ie5.5\'])
                     $data = str_replace("\t", "<pre style=\"display: inline;\">\t</pre>", $data);
                  elseif (!$context[\'browser\'][\'is_gecko\'])
                     $data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data);
               }'),
            'block_level' => true,
         ),

Martinike


Matthew K.

array(
'tag' => 'pawn',
'type' => 'unparsed_content',
'content' => '<div class="codeheader">' . $txt['pawn'] . ':</div><div class="code">' . ($context['browser']['is_gecko'] ? '<pre style="margin-top: 0; display: inline;">$1</pre>' : '$1') . '</div>',
'validate' => create_function('&$tag, &$data, $disabled', '
global $context;

               if (!isset($disabled['pawn']))
{

$data = str_replace(
array(
'public',
'return',
'sizeof',
'switch',
'true',
'false',
'if',
'new',
'else',
'for',
'while',
'(',
')',
'[',
']',
'{',
'}'
),
array(
'<span style="color: blue;">public</span>',
'<span style="color: blue;">return</span>',
'<span style="color: blue;">sizeof</span>',
'<span style="color: blue;">switch</span>',
'<span style="color: blue;">true</span>',
'<span style="color: blue;">false</span>',
'<span style="color: blue;">if</span>',
'<span style="color: blue;">new</span>',
'<span style="color: blue;">else</span>',
'<span style="color: blue;">for</span>',
'<span style="color: blue;">while</span>',
'<span style="color: red;">(</span>',
'<span style="color: red;">)</span>',
'<span style="color: red;">[</span>',
'<span style="color: red;">]</span>',
'<span style="color: red;">{</span>',
'<span style="color: red;">}</span>',
'|||'
), $data);

$data = preg_replace(
array(
'~#(.+?)\<br \/>~is',
'~\/\/(.+?)\<br \/\>~i',
'~\/\*(.+?)\*\/~i'
),
array(
'<span style="color: blue;">#$1<br /></span>',
'<span style="color: green;">//$1<br /></span>',
'<span style="color: green;">/*$1*/</span>'
), $data);
$data = str_replace('|||', '\'', $data);

// Older browsers are annoying, aren\'t they?
if ($context['browser']['is_ie4'] || $context['browser']['is_ie5'] || $context['browser']['is_ie5.5'])
$data = str_replace("\t", "<pre style=\"display: inline;\">\t</pre>", $data);
elseif (!$context[\'browser\'][\'is_gecko\'])
$data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data);
}'),
'block_level' => true,
         ),

Martinike

Now 1 error:
Parse error: syntax error, unexpected T_STRING in /home/a9991594/public_html/forum/Sources/Subs.php on line 1424

Matthew K.


Martinike

               if (!isset($disabled['pawn']))

Matthew K.

Code (Find) Select
'validate' => create_function('&$tag, &$data, $disabled', '
Code (Replace) Select
'validate' => create_function('&$tag, &$data, $disabled',

Try that.

Martinike

New error...

Parse error: syntax error, unexpected T_GLOBAL in /home/a9991594/public_html/forum/Sources/Subs.php on line 1422

global $context;

Matthew K.

Shouldn't be the problem, but try this: array(
'tag' => 'pawn',
'type' => 'unparsed_content',
'content' => '<div class="codeheader">' . $txt['pawn'] . ':</div><div class="code">' . ($context['browser']['is_gecko'] ? '<pre style="margin-top: 0; display: inline;">$1</pre>' : '$1') . '</div>',
'validate' => create_function('&$tag, &$data, $disabled', '
global $context;

               if (!isset($disabled[\'pawn\']))
{

$data = str_replace(
array(
'public',
'return',
'sizeof',
'switch',
'true',
'false',
'if',
'new',
'else',
'for',
'while',
'(',
')',
'[',
']',
'{',
'}'
),
array(
'<span style="color: blue;">public</span>',
'<span style="color: blue;">return</span>',
'<span style="color: blue;">sizeof</span>',
'<span style="color: blue;">switch</span>',
'<span style="color: blue;">true</span>',
'<span style="color: blue;">false</span>',
'<span style="color: blue;">if</span>',
'<span style="color: blue;">new</span>',
'<span style="color: blue;">else</span>',
'<span style="color: blue;">for</span>',
'<span style="color: blue;">while</span>',
'<span style="color: red;">(</span>',
'<span style="color: red;">)</span>',
'<span style="color: red;">[</span>',
'<span style="color: red;">]</span>',
'<span style="color: red;">{</span>',
'<span style="color: red;">}</span>',
'|||'
), $data);

$data = preg_replace(
array(
'~#(.+?)\<br \/>~is',
'~\/\/(.+?)\<br \/\>~i',
'~\/\*(.+?)\*\/~i'
),
array(
'<span style="color: blue;">#$1<br /></span>',
'<span style="color: green;">//$1<br /></span>',
'<span style="color: green;">/*$1*/</span>'
), $data);
$data = str_replace('|||', '\'', $data);

// Older browsers are annoying, aren\'t they?
if ($context['browser']['is_ie4'] || $context['browser']['is_ie5'] || $context['browser']['is_ie5.5'])
$data = str_replace("\t", "<pre style=\"display: inline;\">\t</pre>", $data);
elseif (!$context[\'browser\'][\'is_gecko\'])
$data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data);
}'),
'block_level' => true,
         ),

Martinike

New error again.. :(

Parse error: syntax error, unexpected T_PUBLIC in /home/a9991594/public_html/forum/Sources/Subs.php on line 1429

'public',

AndreT

Hi Martinike.

You'll have to escape the 'public' so it becomes \'public\' or else the 'public' breaks out of the string.

I'm Andre9977.

Martinike

Quote from: Andre_ on February 08, 2010, 01:46:23 PM
Hi Martinike.

You'll have to escape the 'public' so it becomes \'public\' or else the 'public' breaks out of the string.

I'm Andre9977.
Hmm...?
(Cant understand.. sorry)

Matthew K.

Andre is right, I apologize. array(
'tag' => 'pawn',
'type' => 'unparsed_content',
'content' => '<div class="codeheader">' . $txt['pawn'] . ':</div><div class="code">' . ($context['browser']['is_gecko'] ? '<pre style="margin-top: 0; display: inline;">$1</pre>' : '$1') . '</div>',
'validate' => create_function('&$tag, &$data, $disabled', '
global $context;

               if (!isset($disabled[\'pawn\']))
{

$data = str_replace(
array(
\'public\',
\'return\',
\'sizeof\',
\'switch\',
\'true\',
\'false\',
\'if\',
\'new\',
\'else\',
\'for\',
\'while\',
\'(\',
\')\',
\'[\',
\']\',
\'{\',
\'}\'
),
array(
'<span style="color: blue;">public</span>',
'<span style="color: blue;">return</span>',
'<span style="color: blue;">sizeof</span>',
'<span style="color: blue;">switch</span>',
'<span style="color: blue;">true</span>',
'<span style="color: blue;">false</span>',
'<span style="color: blue;">if</span>',
'<span style="color: blue;">new</span>',
'<span style="color: blue;">else</span>',
'<span style="color: blue;">for</span>',
'<span style="color: blue;">while</span>',
'<span style="color: red;">(</span>',
'<span style="color: red;">)</span>',
'<span style="color: red;">[</span>',
'<span style="color: red;">]</span>',
'<span style="color: red;">{</span>',
'<span style="color: red;">}</span>',
'|||'
), $data);

$data = preg_replace(
array(
'~#(.+?)\<br \/>~is',
'~\/\/(.+?)\<br \/\>~i',
'~\/\*(.+?)\*\/~i'
),
array(
'<span style="color: blue;">#$1<br /></span>',
'<span style="color: green;">//$1<br /></span>',
'<span style="color: green;">/*$1*/</span>'
), $data);
$data = str_replace('|||', '\'', $data);

// Older browsers are annoying, aren\'t they?
if ($context['browser']['is_ie4'] || $context['browser']['is_ie5'] || $context['browser']['is_ie5.5'])
$data = str_replace("\t", "<pre style=\"display: inline;\">\t</pre>", $data);
elseif (!$context[\'browser\'][\'is_gecko\'])
$data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data);
}'),
'block_level' => true,
         ),

Martinike

Parse error: syntax error, unexpected T_STRING in /home/a9991594/public_html/forum/Sources/Subs.php on line 1448

               '<span style="color: blue;">public</span>',

Again... I hate that error's :(

Matthew K.

I apologize for the mix up, I was unaware of a string at the top therefore I messed up an edit.

This should work for you: array(
'tag' => 'pawn',
'type' => 'unparsed_content',
'content' => '<div class="codeheader">' . $txt['pawn'] . ':</div><div class="code">' . ($context['browser']['is_gecko'] ? '<pre style="margin-top: 0; display: inline;">$1</pre>' : '$1') . '</div>',
'validate' => create_function('&$tag, &$data, $disabled', '
global $context;

               if (!isset($disabled[\'pawn\']))
{

$data = str_replace(
array(
\'public\',
\'return\',
\'sizeof\',
\'switch\',
\'true\',
\'false\',
\'if\',
\'new\',
\'else\',
\'for\',
\'while\',
\'(\',
\')\',
\'[\',
\']\',
\'{\',
\'}\'
),
array(
\'<span style="color: blue;">public</span>\',
\'<span style="color: blue;">return</span>\',
\'<span style="color: blue;">sizeof</span>\',
\'<span style="color: blue;">switch</span>\',
\'<span style="color: blue;">true</span>\',
\'<span style="color: blue;">false</span>\',
\'<span style="color: blue;">if</span>\',
\'<span style="color: blue;">new</span>\',
\'<span style="color: blue;">else</span>\',
\'<span style="color: blue;">for</span>\',
\'<span style="color: blue;">while</span>\',
\'<span style="color: red;">(</span>\',
\'<span style="color: red;">)</span>\',
\'<span style="color: red;">[</span>\',
\'<span style="color: red;">]</span>\',
\'<span style="color: red;">{</span>\',
\'<span style="color: red;">}</span>\',
\'|||\'
), $data);

$data = preg_replace(
array(
'~#(.+?)\<br \/>~is',
'~\/\/(.+?)\<br \/\>~i',
'~\/\*(.+?)\*\/~i'
),
array(
'<span style="color: blue;">#$1<br /></span>',
'<span style="color: green;">//$1<br /></span>',
'<span style="color: green;">/*$1*/</span>'
), $data);
$data = str_replace('|||', '\'', $data);

// Older browsers are annoying, aren\'t they?
if ($context['browser']['is_ie4'] || $context['browser']['is_ie5'] || $context['browser']['is_ie5.5'])
$data = str_replace("\t", "<pre style=\"display: inline;\">\t</pre>", $data);
elseif (!$context[\'browser\'][\'is_gecko\'])
$data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data);
}'),
'block_level' => true,
         ),

Martinike

Parse error: syntax error, unexpected '~' in /home/a9991594/public_html/forum/Sources/Subs.php on line 1470


'~#(.+?)\<br \/>~is',

>.< , i think next is more new error...

Matthew K.

Try this:
Code (Find) Select
'~#(.+?)\<br \/>~is',
Code (Replace) Select
'\~#(.+?)\<br \/>\~is',

Martinike

#18
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/a9991594/public_html/forum/Sources/Subs.php on line 1470

Parse error: syntax error, unexpected '~' in /home/a9991594/public_html/forum/Sources/Subs.php on line 1470


'\~#(.+?)\<br \/>\~is',

// I fixed one error, but two error not.

'~\#(.+?)\<br \/>\~is',

AndreT

I'm afraid there's more of escaping to do. In the str_replace first array for example (for the second parameter as well of course)...


               $data = preg_replace(
               array(
                  \'~#(.+?)\<br \/>~is\',
                  \'~\/\/(.+?)\<br \/\>~i\',
                  \'~\/\*(.+?)\*\/~i\'
               ),
               array(
                  \'<span style="color: blue;">#$1<br /></span>\',
                  \'<span style="color: green;">//$1<br /></span>\',
                  \'<span style="color: green;">/*$1*/</span>\'
               ), $data);
               $data = str_replace(\'|||\', \'\'\', $data);


               if ($context[\'browser\'][\'is_ie4\'] || $context[\'browser\'][\'is_ie5\'] || $context[\'browser\'][\'is_ie5.5\'])
                  $data = str_replace("\t", "<pre style=\"display: inline;\">\t</pre>", $data);
               elseif (!$context[\'browser\'][\'is_gecko\'])
                  $data = str_replace("\t", "<span style=\"white-space: pre;\">\t</span>", $data);

Advertisement: