Welcome, Guest. Please Login or Register.
May 14, 2025, 06:57:36 PM
Home Help Search Log in Register
News: SMF is the next generation in forum software, almost completely re-written from the ground up, make sure you don't fall for cheap imitations that suffer from feature bloat!

YaBB SE Community  |  Development  |  Mod Ideas and Creation  |  [PHP]tag in YaBBSE[/php] « previous next »
Pages: [1] Reply Ignore Print
Author Topic: [PHP]tag in YaBBSE[/php]  (Read 1696 times)
Aeon
Full Member
***
Posts: 235


Chaos Forces

never_mind86@hotmail.com WWW
[PHP]tag in YaBBSE[/php]
« on: August 01, 2003, 05:28:59 PM »
Reply with quote

I think this thing was discussed before but I couldn't find it ..
anyway I was on hotscripts.com forums and I saw it .. I think this great thing will be greater if it was in YabbSE ;)
« Last Edit: August 01, 2003, 05:50:20 PM by Aeon » Logged

I still don't know what Classes and Object-Orinted do!!?
do you know what they do and why they existed ?!
please tell me and I will appreciate it ..
[Unknown]
Global Moderator
YaBB God
*****
Posts: 7830


ICQ - 179721867unknownbrackets@hotmail.com WWW
Re:[PHP]tag is YaBBSE[/php]
« Reply #1 on: August 01, 2003, 05:46:47 PM »
Reply with quote

To note, he means...

<?php phpifo();?>

Should parse to something like

PHP<?php phpinfo();?>

Except it would be color coded...

-[Unknown]
Logged
Aeon
Full Member
***
Posts: 235


Chaos Forces

never_mind86@hotmail.com WWW
Re:[PHP]tag is YaBBSE[/php]
« Reply #2 on: August 01, 2003, 05:51:12 PM »
Reply with quote

QuoteTo note, he means...

<?php phpifo();?>

Should parse to something like

PHPCode:
<?php phpinfo();?>


Except it would be color coded...
exactly
Logged

I still don't know what Classes and Object-Orinted do!!?
do you know what they do and why they existed ?!
please tell me and I will appreciate it ..
Ben_S
Disciple of Joe
Support Team
YaBB God
*****
Posts: 1586


I Love YaBB SE!

WWW
Re:[PHP]tag in YaBBSE[/php]
« Reply #3 on: August 01, 2003, 06:17:40 PM »
Reply with quote

I'm sure someones done this mod before, may have dreamed that though
Logged
Anguz
YaBB God
*****
Posts: 641


llama me?!

WWW
Re:[PHP]tag in YaBBSE[/php]
« Reply #4 on: August 02, 2003, 01:48:22 AM »
Reply with quote

that'd be very nice  :o
Logged

My Mods: Avatar & Sig Size Control, No Show Msg Subject, Msg URL Composer, Built-in Avatar Rand, Built-in Sig Rand, Remove New-lines Excess, Show All Stars, Search Bar, Smart URLs
[Unknown]
Global Moderator
YaBB God
*****
Posts: 7830


ICQ - 179721867unknownbrackets@hotmail.com WWW
Re:[PHP]tag in YaBBSE[/php]
« Reply #5 on: August 02, 2003, 03:39:15 AM »
Reply with quote

Subs.php, find:
function doUBBC($message,$enableSmilies = 1)
{
//echo $message;
   global $settings, $text, $txt;

   $parts = split('\[\/?code\]', ' ' . $message);

   for ($i = 0; $i < count($parts); $i++)
   {
      if ($i % 2 == 0)
      {
         $parts[$i] = str_replace(array('$', '[[', ']]'), array('&#36;', '{<{', '}>}'), $parts[$i]);
         if ($i > 0)
            $parts[$i] = '</font></td></tr></table></td></tr></table>' . $parts[$i];
         $parts[$i] = preg_replace("/([\n >\(])([\w\-_]+?):\/\/([\w\-_@:]+)((\.[\w\-_]+)+(:[\d]+)?((\/[\w\-_%]+(\.[\w\-_%]+)*)|(\/[~]?[\w\-_%]*))*(\/?(\?[&;=\w\+%]+)*)?(#[\w\-_]*)?)/", "\\1[url=\\2://\\3\\4]\\2://\\3\\4[/url]", $parts[$i]);
         $parts[$i] = preg_replace("/([\n >\(])www((\.[\w\-_]+)+(:[\d]+)?((\/[\w\-_%]+(\.[\w\-_%]+)*)|(\/[~]?[\w\-_%]*))*(\/?(\?[&;=\w\+%]+)*)?(#[\w\-_]*)?)/", "\\1[url=http://www\\2]www\\2[/url]", $parts[$i]);
         $parts[$i] = doparsecodesmilies($parts[$i], $enableSmilies);
      }
      elseif ($i <= count($parts) - 1)
         $parts[$i] = '<table border="0" cellpadding="0" cellspacing="0"><tr><td><font size="1"><b>' . $txt['yse238'] . ':</b></font></td></tr></table><table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#000000"><tr><td><table border="0" cellspacing="1" cellpadding="2" width="100%"><tr><td class="code"><font face="Courier new">' . $parts[$i];
   }
   $message = substr(implode('', $parts), 1);
   $message = str_replace(
      array('{<{', '}>}', '  ', "\t", "\n\r", "\r", "\n"),
      array('[', ']', '&nbsp; ', '&nbsp; &nbsp; ', '<br />', '<br />', '<br />'), $message);
/*   $message = str_replace('{<{','[',$message);
   $message = str_replace('}>}',']',$message);
   // $message = stripslashes($message); // Maybe you'll have to uncomment this
   $message = str_replace("  ","&nbsp; ",$message);
   $message = str_replace("\t","&nbsp; &nbsp; ",$message);
   $message = str_replace("\n\r","<br>",$message);
   $message = str_replace("\r","<br>",$message);
   $message = str_replace("\n","<br>",$message);*/

   return $message;

}


Replace:
function doUBBC($message,$enableSmilies = 1)
{
   global $settings, $text, $txt;

   $parts = split('\[\/?code\]', ' ' . $message);

   for ($i = 0; $i < count($parts); $i++)
   {
      if ($i % 2 == 0)
      {
         if (strpos($parts[$i], '[php]') !== false)
         {
            $phpparts = split('\[\/?php\]', ' ' . $parts[$i]);
            for ($phpi = 0; $phpi < count($phpparts); $phpi++)
            {
               if ($phpi % 2 == 0)
               {
                  $phpparts[$i] = str_replace(array('$', '[[', ']]'), array('&#36;', '{<{', '}>}'), $phpparts[$i]);
                  if ($i > 0 && $phplasti != $i)
                  {
                     $phpparts[$i] = '</font></td></tr></table></td></tr></table>' . $phpparts[$i];
                     $phplasti = $i;
                  }
                  $phpparts[$i] = preg_replace("/([\n >\(])([\w\-_]+?):\/\/([\w\-_@:]+)((\.[\w\-_]+)+(:[\d]+)?((\/[\w\-_%]+(\.[\w\-_%]+)*)|(\/[~]?[\w\-_%]*))*(\/?(\?[&;=\w\+%]+)*)?(#[\w\-_]*)?)/", "\\1[url=\\2://\\3\\4]\\2://\\3\\4[/url]", $phpparts[$i]);
                  $phpparts[$i] = preg_replace("/([\n >\(])www((\.[\w\-_]+)+(:[\d]+)?((\/[\w\-_%]+(\.[\w\-_%]+)*)|(\/[~]?[\w\-_%]*))*(\/?(\?[&;=\w\+%]+)*)?(#[\w\-_]*)?)/", "\\1[url=http://www\\2]www\\2[/url]", $phpparts[$i]);
                  $phpparts[$i] = doparsecodesmilies($phpparts[$i], $enableSmilies);
               }
               elseif ($phpi < count($phpparts))
               {
                  $phpparts[$phpi] = phphighlight($phpparts[$phpi]);
               }
            }
            $parts[$i] = substr(implode('', $phpparts), 1);
         }
      }
      elseif ($i <= count($parts) - 1)
         $parts[$i] = '<table border="0" cellpadding="0" cellspacing="0"><tr><td><font size="1"><b>' . $txt['yse238'] . ':</b></font></td></tr></table><table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#000000"><tr><td><table border="0" cellspacing="1" cellpadding="2" width="100%"><tr><td class="code"><font face="Courier new">' . $parts[$i];
   }

   $message = substr(implode('', $parts), 1);

   $message = str_replace(
      array('{<{', '}>}', '  ', "\t", "\n\r", "\r", "\n"),
      array('[', ']', '&nbsp; ', '&nbsp; &nbsp; ', '<br />', '<br />', '<br />'), $message);

   return $message;
}


Find:
function phphighlight($code)
{
   if (floor(phpversion()) < 4)
      $buffer=$code;
   else
   {
      $code = stripslashes($code);
      $code = stripslashes($code);
      $code = str_replace(array('&gt;', '&lt;', '&#36;', '&quot;'), array('>', '<', '$', '"'), $code);

      if (!strstr($code, '<?'))
      {
         $code="<?php\n".trim($code)."\n?" .'>';
         
$addedtags = 1;
      }
      ob_start();
      
$oldlevel = error_reporting(0);
      highlight_string(
$code);
      error_reporting(
$oldlevel);
      
$buffer = ob_get_contents();
      ob_end_clean();
      
$buffer = str_replace('&quot;', '"', $buffer);
   }
   return '
<table border="0" cellpadding="0" cellspacing="0"><tr><td><font size="1"><b>PHP:</b></font></td></tr><table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#000000"><tr><td><table border="0" cellspacing="1" cellpadding="2" width="100%"><tr><td class="quote">' . addslashes(addslashes($buffer)) . '</td></tr></table></td></tr></table>';
}


Replace:
function phphighlight($code)
{
   $code = str_replace('<br />', "\n", un_html_entities($code));

   if (!strstr($code, '<?'))
   {
      $code = "<?php\n" . trim($code) . "\n?" . '>';
      
$addedtags = true;
   }
   else
      
$addedtags = false;

   if ((float) PHP_VERSION < 4.2)
   {
      ob_start();
      
$oldlevel = error_reporting(0);
      highlight_string(
$code);
      error_reporting(
$oldlevel);
      
$buffer = str_replace("\n", '', ob_get_contents());
      ob_end_clean();
   }
   else
      
$buffer = str_replace("\n", '', highlight_string($code, true));

   if (
$addedtags)
      
$buffer = preg_replace(array('~^<code><font color="[^"]+">(<font color="[^"]+">)&lt;\?php<br />~i', '~<font color="[^"]+">\?&gt;</font></font></code>~i'), array('\\1', ''), $buffer);

   return '
<table border="0" cellpadding="0" cellspacing="0"><tr><td><font size="1"><b>PHP:</b></font></td></tr><table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#000000"><tr><td><table border="0" cellspacing="1" cellpadding="2" width="100%"><tr><td class="code">' . str_replace("'", '&#039;', $buffer) . '</td></tr></table></td></tr></table>';
}


;).

-[Unknown]
Logged
Aeon
Full Member
***
Posts: 235


Chaos Forces

never_mind86@hotmail.com WWW
Re:[PHP]tag in YaBBSE[/php]
« Reply #6 on: August 02, 2003, 08:20:56 AM »
Reply with quote

a new bug appeared !!? the [img] tag is now not working ?!
also how can I change the background color and the font for it ?
I tried changing the font in doUBBC(); but nothing changed ...
thanks in advance .. and thanks for the fast mod making ;)
« Last Edit: August 02, 2003, 08:23:35 AM by Aeon » Logged

I still don't know what Classes and Object-Orinted do!!?
do you know what they do and why they existed ?!
please tell me and I will appreciate it ..
[Unknown]
Global Moderator
YaBB God
*****
Posts: 7830


ICQ - 179721867unknownbrackets@hotmail.com WWW
Re:[PHP]tag in YaBBSE[/php]
« Reply #7 on: August 02, 2003, 04:54:20 PM »
Reply with quote

Very odd..

PHP is coloring it, you can't change the colors.

-[Unknown]
Logged
Pages: [1] Reply Ignore Print 
YaBB SE Community  |  Development  |  Mod Ideas and Creation  |  [PHP]tag in YaBBSE[/php] « previous - next »
 


Powered by MySQL Powered by PHP YaBB SE Community | Powered by YaBB SE
© 2001-2003, YaBB SE Dev Team. All Rights Reserved.
SMF 2.1.4 © 2023, Simple Machines
Valid XHTML 1.0! Valid CSS

Page created in 0.029 seconds with 21 queries.