Welcome to Esato.com




Need some help with a PHP algorithm

Click to view updated thread with images


Posted by Krubach
OK.
This one's for hardcore PHP programmers (namely nuke_phpbb forums).
I want to do something similar to what happens here with Esato's hosted images. This is, and unlogged (anonymous user) can't view the pic in a post, and instead, another pic is placed.

So i need to parse a $message and replace any URL in <img> tags and between [img][/img] BBcode tags (don't really know if both aplly).

I'm completely lost here...
Maybe laffen could give me a snip of his code...

I'm very thankful to anyone who can point me a direction.

Cheers.


Posted by batesie
good luck! have u tried www.phpBB.com or somethin simlar?

Posted by gardar
I have this running on my page, but its not nuke, its xoops, i can let you have my script if i will find this thread to morrow when im at a pc :P

Posted by simpsons
Statndard PHP stuff like search and replace using 'ereg' bits should do what you want .

Posted by Krubach
I tried something like the "ereg" thing. Namely "preg_replace" but i failed to get it working.

A code snip would be very much appreciated.

Posted by Krubach
OK. I got it.

Just before the "Parse smilies" section in viewtopic.php

put this:

////////////////////////////////////////////////////////////////////////
// TWEAK TO REMOVE IMAGE DISPLAY FROM NOT LOGGED IN USERS
//
// PG: 2005/04/13
////////////////////////////////////////////////////////////////////////
if (!$userdata['session_logged_in'])
{
$message = ereg_replace("<img[^>]*>", "<img src="modules/Forums/images/logintoview.jpg">", $message);
}


And voilá!

[ This Message was edited by: Krubach on 2005-04-13 20:32 ]

Posted by simpsons
No Wurries... sorted !


Click to view updated thread with images


© Esato.com - From the Esato mobile phone discussion forum