vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   php plugin (https://vborg.vbsupport.ru/showthread.php?t=227200)

Ghostt 11-01-2009 04:58 PM

php plugin
 
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.
PHP Code:

<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

Quote:

Originally Posted by Zachery (Post 1909956)
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 [DATE]1257600267[/DATE] at [TIME]1257600267[/TIME] ---------------

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?
PHP Code:

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:
PHP Code:

<if condition="$bbuserinfo['userid']">

stuff
<else />
</if> 

You want:
PHP Code:

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

PHP Code:

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 ? :(
PHP Code:

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

Quote:

Originally Posted by Lynne (Post 1912751)
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

kh99 11-20-2009 03:52 PM

Instead of your plugin using global_start, try using this on global_complete:

Code:

$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

Quote:

Originally Posted by kh99 (Post 1917840)
Instead of your plugin using global_start, try using this on global_complete:

Code:

$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.
PHP Code:

 if(THIS_SCRIPT == showthread)
{ } 


kh99 11-20-2009 08:51 PM

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 [DATE]1258761881[/DATE] at [TIME]1258761881[/TIME] ---------------

OK, you got me curious so I had to go figure it out. :)

You could use:
Code:

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

Ghostt 11-21-2009 11:17 AM

Good job kh99 ! working perfect. we thank you :)


All times are GMT. The time now is 03:25 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01193 seconds
  • Memory Usage 1,781KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (7)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (26)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete