1

Topic: Apply parser.php on a whole site ?

I don't see why I'll do another parser while this is perfect smile

So ... i have seen however some things ... like ...

// Make sure no one attempts to run this script "directly"
if (!defined('PUN'))
    exit;

is it possible to ...

if pun == domain.com = ok

So ... the parser.php would be ok on all the domain/subdomain ???

php and me = 49489 ... so ... if you can help me, it would be great smile

2

Re: Apply parser.php on a whole site ?

you can also write
DEFINE("PUN",TRUE);
at the beginning of your PHP-Script (where you include parser.php)

3

Re: Apply parser.php on a whole site ?

And hack the parser.php for smiles images

function do_smilies($message) .....................
    
       $pun_url='http://www.fantasya.net/forum';       //where the forum found for smile images      i put $pun_url in config.php for use it instead fetch it from DB, for now leave it here


        for ($i = 0; $i < $num_smilies; ++$i)
    $message = preg_replace("#(?<=.\W|\W.|^\W)".preg_quote($smiley_text[$i], '#')."(?=.\W|\W.|\W$)#m", '$1<img src="'.$pun_url.'/img/smilies/'.$smiley_img[$i].'" width="15" height="15" alt="'.$smiley_text[$i].'">$2', $message);
If your people come crazy, you will not need to your mind any more.

4

Re: Apply parser.php on a whole site ?

Hummm ...

That's all ?

No need to apply other include scripts ?

If the answer is "Yes Rod, only parser.php", I'll try tomorrow smile it would be great

5

Re: Apply parser.php on a whole site ?

I used in my front page and my articles of my site, YES Rod big_smile

If your people come crazy, you will not need to your mind any more.

6

Re: Apply parser.php on a whole site ?

I have tried ... nothing happens sad

I have this ...

all pages on my site call config.inc

This config.inc has inside

DEFINE("PUN",TRUE);

require "../forum/config.php";

require "../forum/include/functions.php";

require "../forum/include/parser.php";

Actually my root is http://www.sortons.net
My forum is http://www.sortons.net/forum/
My dev new xhtml site is in another folder ... like forum.

Nothing happens (no errors, but if I take the example of the transformation of URL by a CLICKING url ... nothing : url stays TEXT only)

sad

7

Re: Apply parser.php on a whole site ?

you not need 
    DEFINE("PUN",TRUE);

if include config.php

you must use

require "../forum/config.php";

require "../forum/include/functions.php";

require "../forum/include/parser.php";

print parse_message('your text');

i need more info

If your people come crazy, you will not need to your mind any more.

8 (edited by zaher 2004-10-06 00:05)

Re: Apply parser.php on a whole site ?

did you mean

heeeeeeeeeelp ! :)

If your people come crazy, you will not need to your mind any more.

9

Re: Apply parser.php on a whole site ?

I don't understand your

print parse_message('your text');

I thought by putting parser.php, it applies automatically ..

How to do ?

10

Re: Apply parser.php on a whole site ?

see this: http://de3.php.net/manual/en/ref.outcontrol.php big_smile

put in your php-scripts (at the beginning) something like:

<?php
require "../forum/config.php";
require "../forum/include/functions.php";
require "../forum/include/parser.php";
ob_start();
?>

Then put your document in here and at at the bottom:

<?php
print parse_message(ob_get_contents());
ob_end_clean();
?>

11 (edited by Johi 2004-10-06 18:23)

Re: Apply parser.php on a whole site ?

Didn't test this out. Hope it works.

-----

BTW: You can also use something like this:

at the beginning:

<?php
require "../forum/config.php";
require "../forum/include/functions.php";
require "../forum/include/parser.php";
ob_start("parse_message");
?>

Then put your document in here and at at the bottom:

<?php
ob_end_flush();
?>

[ I think in this case you won't need the ob_end_flush() thingy, so including the code above in your config.inc would be enough]

(Didn't test this either...)

12

Re: Apply parser.php on a whole site ?

Ok ... I thought the Holy Grail was near ... but it was a dream.

When I want to apply

ob_start(parse_message);

In my config.inc, the whole HTML / XHTML code is not interpreted by the browser : I see my code as if I saw it in NotePad ...

sad

13

Re: Apply parser.php on a whole site ?

Whoops.
Try using ob_start("parse_message");

Don't know if that was the failure.
Didn't use PHP for some time. big_smile

I'll test it out locally too, to see if it works.

What version of PHP do you have btw.?
ob_start is available from 4 and up afaik.

14

Re: Apply parser.php on a whole site ?

i agree with Johi .

If your people come crazy, you will not need to your mind any more.

15 (edited by Johi 2004-10-06 18:38)

Re: Apply parser.php on a whole site ?

Use my first code. It will (hopefully) work.

At the beginning add:

<?php
require "../forum/config.php";
require "../forum/include/functions.php";
require "../forum/include/parser.php";
ob_start(parse_message);
?>

finally add at the end:

<?php
print parse_message(ob_get_contents(), '1');
ob_end_clean();
?>

And remeber to fix the do_smilies() function like zaher said.


EDIT: hm. didn't do it. i'll have to look at it sometimes later.
EDIT: Found another. parse_message() requires 2 arguments!  (2nd says wether to use smilies ('1') or not ('0') )
EDIT: Found some other conflicts: parse_message() uses pun_htmlspecialchars(), which destroyes your markup [replaces "<" with "<" for example] also there are many references to "$pun_config" which is a value coming out of the database. Seems a bit tricky.

16

Re: Apply parser.php on a whole site ?

http://www.techweavers.net/~shayne/parser.zip

...used by doing...

require_once("parser.inc");
$string = parse_message($string);

...i know this, because i use it smile

17

Re: Apply parser.php on a whole site ?

...what my parser does is basically removes the need for other files, makes it a one file solution.  You may have pathing issues with the smiles, beyond that it outta just work.

Questions, comments, let me know.

18

Re: Apply parser.php on a whole site ?

Yes ... questions and comments ...

1. where do I apply finally the code
2. the best is now : WHICH CODE have I put now ?

argh ...

19 (edited by jacobswell 2004-10-06 23:30)

Re: Apply parser.php on a whole site ?

<?php
define('PUN', true);
$pun_root = 'forum/'; // change here
require $pun_root ."include/parser.php";
ob_start();
?>

here comes the html code that you want

<?php
$contents = ob_get_contents();
// apply bbcode
$contents = do_bbcode($contents);
// if you want to apply smilies also
$contents = do_smilies($contents);
print $contents;
?>

i think it's ok with this code.

Edit:
but smilies will have problem because if you check the do_smilies function, you can see the code: src=img/smilies/... blah...
if you want to apply it change it like

$message = preg_replace("#(?<=.\W|\W.|^\W)".preg_quote($smiley_text[$i], '#')."(?=.\W|\W.|\W$)#m", '$1<img src="'.$pun_root.'img/smilies/'.$smiley_img[$i].'" width="15" height="15" alt="'.$smiley_text[$i].'">$2', $message);

and $pun_root should be declared as global in do_smilies function.

Edit:
I think i forgot including functions.php

20

Re: Apply parser.php on a whole site ?

I think I'm very dumb ... yes yes ...

OK I put

<?php
define('PUN', true);
$pun_root = 'forum/'; // change here
require $pun_root ."include/parser.php";
ob_start();
?>

in my config.inc ... ok cool perfect ... the great life.

But WHERE must I put

<?php
$contents = ob_get_contents();
// apply bbcode
$contents = do_bbcode($contents);
// if you want to apply smilies also
$contents = do_smilies($contents);
print $contents;
?>

After ? In body ? On another planet ? ... don't understand ...

For the moment I would like only apply BBcode in fact ... until I realize my own smiles ...

Re: Apply parser.php on a whole site ?

after finishing htmlcode for example

here comes html code...
</body>
</html>
<?php
$contents = ob_get_contents();
... blah...

22

Re: Apply parser.php on a whole site ?

Ok it doesn't work : I'll drop it, I'm fed up with this code which can't be applied on MY site sad

Re: Apply parser.php on a whole site ?

could you show us the code of config.inc and some php files so that we can find the best solution?

24

Re: Apply parser.php on a whole site ?

keep going, dont give up.

If your people come crazy, you will not need to your mind any more.

Re: Apply parser.php on a whole site ?

I don't have the energy to read through the whole topic, but I can tell you this much. parser.php requires access to a bunch of global PunBB variables (e.g. $pun_config, $cur_user, $lang_common etc). These must be set in order for parser.php to work properly. The proper way to do it is this:

// Define $pun_root. The relative path to the forum root directory. E.g.
$pun_root = '../../';

// Include common.php
require $pun_root.'include/common.php';

// Now we can include parser.php
require $pun_root.'include/parser.php';

Keep in mind though that common.php will do lots of stuff you might not need. It will connect to the database, authorise the current user etc.

"Programming is like sex: one mistake and you have to support it for the rest of your life."