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

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
Kyrillos
Forum Newbie
Posts: 3
Joined: Wed Jan 03, 2007 6:23 pm

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

Post 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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Kyrillos
Forum Newbie
Posts: 3
Joined: Wed Jan 03, 2007 6:23 pm

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Sorry, that would be work on my part and little learning on yours.
Kyrillos
Forum Newbie
Posts: 3
Joined: Wed Jan 03, 2007 6:23 pm

Post 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
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post 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.
Post Reply