Page 1 of 1

removing quoted text from a phpbb message I NEED HELP!!!!!!!

Posted: Wed Jan 03, 2007 6:35 pm
by Kyrillos
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


alright well what ive been trying to in this php script is strip the bbcode off a message which i did successfully, and now im trying to strip the quote bbcode aswell as the quoted text, and only leave the rest of the message, so far ive been unsuccessful with the quoted message, but i have removed the quote bbcode please help i desperately need it. 

NOTE: THERE ARE SOME TCL COLOR CODES IN HERE, BECAUSE THIS SCRIPT RELAYS THE DATA TO AN IRC EGGDROP SO PLEASE IGNORE THE COLOR CODES eg: /00309,01

Code: Select all

<?php

$bb2egg['channel'] = "#zex";
$bb2egg['ids'] = "9 20 21 22 23 24 19"; 
$bb2egg['botip'] = "61.22.33.60";
$bb2egg['botport'] = "1337";
$bb2egg['boardurl'] = "http://teamzex.net/forum";
$bb2egg['pass'] = "password";


function send2egg($mode, $forumid, $topic_id, $user_id, $subject, $message, $poll_title, $forum_name, $post_id)
{

       global $userdata, $bb2egg;
        if ( check_id($forumid) == 0 )
        {
        	return;
        }
        $nick = $userdata['username'];
              
        $message = preg_replace("#\[(.*?)]#si", "", $message);
		$message = str_replace('<br />', "\n", $message);
		$message = str_replace('<center>', "", $message);
		$message = str_replace("\n", "", $message); 
		$message = preg_replace('/\[quote="(.*?)"](.*?)quote]/','',$message);
		  
if (strlen($message) > 50) { $text = substr($message,0,50)."..."; }
else { $text = $message; }

        switch( $mode )
        {
	     case 'newtopic':
		    if ( $poll_title != '' )
              {
              $text2  = "\00309,01\002[»]\00314,01\002 New Poll Started By:\00300,01\002 $nick\00314,01\002 in\00300,01\002 $forum_name \00309,01[«]\002<br>";
              }
		      else {
              $text2  = "\00309,01\002[»]\00314,01\002 New Topic Posted By: \00300,01\002 $nick \00309,01[«]\002<br>";
		      }
	 	break;
     	case 'reply':
           $text2  = "\002\00309,01[»]\00314,01\002 New Reply Posted By:\00300,01\002 $nick \00309,01[«]\002<br>";
		   break;
	    default:

		break;
       }
        	
        if ( $subject != '' )
 		{
	        $text2  .= "\002\00309,01[»]\002 \00314,01Subject:\002\00300,01 $subject \00309,01[«]\002 <br>";
            $text2  .= "\002\00309,01[»]\002 \00314,01Message:\002\00300,01 $text \00309,01[«]\002 <br>";
        }
        else
        {
              $text2  .= "\002\00309,01[»]\002 \00314,01Message:\002\00300,01 $text \00309,01[«]\002<br>";
        }

        $text2 .= "\002\00309,01[»]\002 \00314,01Link:\00300,01\002 \00300,01" . $bb2egg['boardurl'] . "/viewtopic.php?t=$topic_id#$post_id \00309,01[«]\002";
        if ( $message == "" ) { 
            $text2 = ""; 
          }
	    phpbb2egg($text2);

}

function phpbb2egg($text)
{
global $bb2egg;

        if ( $text == '') {
        return;
        }

        $text = ereg_replace(";", ":", $text);
        $text = ereg_replace("<br>", ";", $text);



            $fp = fsockopen($bb2egg['botip'], $bb2egg['botport'], $errno, $errstr, 30);

            if ($fp) {
                fputs($fp, md5($bb2egg['pass']) ." ". $bb2egg['channel'] ." $text\n");
                sleep(2);
                fclose($fp);
            }

}


function check_id($current)
{
global $bb2egg;

        $forumids=explode(" ", $bb2egg['ids']);

        while ( list($n, $id) = each($forumids))
        {

            if ($id == $current)
            {
				return 1;
            }

        }

        return 0;



}


?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Wed Jan 03, 2007 7:01 pm
by feyd
Since quote tags can be nested I'd suggest using preg_match_all() to find the positions of each of the tags so you can make sure to count the nest properly. Then afterward remove extras, if need be.

Posted: Wed Jan 03, 2007 7:05 pm
by Kyrillos
I really dont quite get what your telling me, im not a php coder i mainly code in tcl so i barely got this code together. Can you please help me out and give me the fix?

Posted: Wed Jan 03, 2007 7:06 pm
by feyd
Sorry, that would be work on my part and little learning on yours.

Posted: Wed Jan 03, 2007 7:09 pm
by Kyrillos
I know but honestly ive been racking my brain on this for 2 days and i want to release this out asap to the eggdrop community. I'm doing this for the tcl community. By doing this for me i would learn how its correctly done. I would never even need to use it again though. This is the only time i will ever use php in my tcl projects

Posted: Wed Jan 03, 2007 10:55 pm
by Kieran Huggins
I think we had a similar thread not long ago... you will probably find what you're looking for by searching (or even browsing) this forum.