View Full Version : php plugin
Ghostt
11-01-2009, 04:58 PM
how to include this php code to vbulletin ? i think wirh plugin and Global start but inst working like that. this script should only be at the showthread.php
function: if the user is logged in.
That special link is disepearing from all post.
<if condition="$bbuserinfo['userid']">
function callback($buffer)
{
return (str_replace("http://example.com", "", $buffer));
}
ob_start("callback");
<else />
</if>
Ghostt
11-03-2009, 09:02 PM
need help here!
Zachery
11-03-2009, 09:04 PM
You couldn't do that in global start I don't believe. You just dont want links to work at all?
Ghostt
11-04-2009, 09:34 AM
You couldn't do that in global start I don't believe. You just dont want links to work at all?
no only a special link should disappear if the user logged in
Ghostt
11-05-2009, 10:12 AM
`no ideas?
Ghostt
11-06-2009, 12:53 PM
need help -.-
--------------- Added 1257600267 at 1257600267 ---------------
help me Oo?
Zachery
11-08-2009, 12:00 PM
if(THIS_SCRIPT == showthread)
{
your code here
}
Ghostt
11-09-2009, 03:56 PM
with global start or what?
like that?
if(THIS_SCRIPT == showthread)
{
<if condition="$bbuserinfo['userid']">
function callback($buffer)
{
return (str_replace("http://example.com", "", $buffer));
}
ob_start("callback");
<else />
</if>
}
Lynne
11-09-2009, 04:20 PM
You are using template conditions in a plugin and that is not going to work. Plugins must only use php. Instead of:
<if condition="$bbuserinfo['userid']">
stuff
<else />
</if> You want:
if ($vbulletin->userinfo['userid']) {
stuff
}
Ghostt
11-09-2009, 04:34 PM
ah ok, then like that? (what about the </else> ) Oo
if(THIS_SCRIPT == showthread)
{
if ($vbulletin->userinfo['userid']) {
function callback($buffer)
{
return (str_replace("http://example.com", "", $buffer));
}
ob_start("callback");
{else /}
}
}
Lynne
11-09-2009, 05:17 PM
Why do you want and else when the else has nothing in it? Just leave it out if you aren't going to do a thing. (Also, please post code in code tags, it's too hard to read otherwise.)
Ghostt
11-09-2009, 05:56 PM
it is not working! also not working with with global start and showtheard start....
can you test it please >.>
if ($vbulletin->userinfo['userid']) {
function callback($buffer)
{
return (str_replace("http://example.com", "", $buffer));
}
ob_start("callback");
Ghostt
11-10-2009, 09:02 PM
help pls!!???? i have ti get it work!
Lynne
11-10-2009, 09:07 PM
If that is all you have in your plugin, then you will get an error since your parenthesis don't add up (you are missing an ending parenthesis).
Ghostt
11-11-2009, 09:42 AM
ok with the end parenthesis } it still not replacing the http://example.com link -.-
can you please test it ? :(
if ($vbulletin->userinfo['userid']) {
function callback($buffer)
{
return (str_replace("example.com", "", $buffer));
}
ob_start("callback");
}
Lynne
11-11-2009, 03:13 PM
No, I can't test it. I have no idea where it is supposed to get $buffer from. Exactly what are you trying to do? Just replace a link in a post for one userid? Why a function? Why aren't you just using str_replace for the $post['message']?
Ghostt
11-11-2009, 03:40 PM
No, I can't test it. I have no idea where it is supposed to get $buffer from. Exactly what are you trying to do? Just replace a link in a post for one userid? Why a function? Why aren't you just using str_replace for the $post['message']?
this php script is fully working outside the forum!!! its replace the link http://example.com with nothing for all user that are logged in!
in other words:
its searching the whole site for "http://example.com" and replace replace it with nothing!
how you would do that using str_replace for the $post['message']?
please show me your code.
what i need is to replace all "http://example.com" to nothing in all posts if the user is logged in!
Ghostt
11-13-2009, 06:18 PM
WHY it isnt working???
Lynne
11-13-2009, 06:30 PM
Are you caching the posts? It could be you have caching on and so it isn't working for those cached posts.
Ghostt
11-13-2009, 08:46 PM
nope it still isnt working , ive deleted the postcache..
Ghostt
11-17-2009, 11:43 AM
why?
Ghostt
11-20-2009, 02:55 PM
on normal site this code is working why not n the forum omg? oO
Instead of your plugin using global_start, try using this on global_complete:
$output = str_replace("example.com", "", $output);
but it does seem kind of dangerous (and slower) to replace it globally on the entire output, it would be better to figure out where to do it just for the post contents.
Ghostt
11-20-2009, 08:40 PM
Instead of your plugin using global_start, try using this on global_complete:
$output = str_replace("example.com", "", $output);
but it does seem kind of dangerous (and slower) to replace it globally on the entire output, it would be better to figure out where to do it just for the post contents.
wow finnay the solution ! big thanks at kh99!
you mean this code could make it faster?
or please give me a better solution i have a big forum so every slow plugin is bad.
if(THIS_SCRIPT == showthread)
{ }
Yeah, you would defintely want to check "THIS_SCRIPT" if you only want it to work on that one page.
To be honest, while it's obviously wise to avoid any unnecessary operations (like checking the entire output when you only need to check the post contents), I don't know that it's enough to be worried about compared to everything else that's going on. If I get a chance I'll look to see if there's a hook to check only the posts. I think I looked a couple days ago and couldn't figure it out, but I'll check again.
--------------- Added 1258761881 at 1258761881 ---------------
OK, you got me curious so I had to go figure it out. :)
You could use:
global $vbulletin;
if ($vbulletin->userinfo['userid'])
{
$post['message'] = str_replace("example.com", "", $post['message']);
}
for the plugin code, and use the "postbit_display_complete" hook, to do it only for posts. This won't do the post titles, if you want the replacement in the titles you'd have to add a second str_replace line for that. (Also I don't think you need to check THIS_SCRIPT this way).
BTW, this is what Lynne suggested back in post #16... (https://vborg.vbsupport.ru/showpost.php?p=1912751&postcount=16)
Ghostt
11-21-2009, 11:17 AM
Good job kh99 ! working perfect. we thank you :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.