PDA

View Full Version : Plugin PHP help


HMBeaty
04-06-2011, 08:04 AM
Ok, so I've been playing around with tearing a few modifications apart and trying to make it to where you have to have a minimum number of posts to post links in signatures. But, I'm a little stuck lol. This is what I have in my plugin so far. Hook location: profile_updatesignature_start
$pagetext =& $this->fetch_field('pagetext', 'post');
$excludedugs = explode(",", $vbulletin->options['usml_siglink_exug']);
if (!is_member_of($vbulletin->userinfo, $excludedugs))
{
if ($vbulletin->options['usml_siglink_enable'] && $vbulletin->userinfo['posts'] < $vbulletin->options['usml_siglink_minposts'])
{
if (stristr($pagetext,'http://') || stristr($pagetext,'www.') || stristr($pagetext,'@') || stristr($pagetext,'[URL') || stristr($pagetext,'[url') || stristr($pagetext,'.com') || stristr($pagetext,'.org') || stristr($pagetext,'.net') || stristr($pagetext,'.gov') || stristr($pagetext,'.biz') || stristr($pagetext,'.info') || stristr($pagetext,'.tv'))
{
standard_error(fetch_error('usml_siglink_msg', $vbulletin->userinfo['username'], $vbulletin->options['usml_siglink_minposts'], $vbulletin->userinfo['posts']));
}
}
}Apparently what I have doesn't work. All I get is a blank white page. So a variable must be wrong and/or some additional code is needed, which I'm not sure what it is, or if the above is even correct to start with. So any guidance you can give me will be greatly appreciated :D

Thank you

--------------- Added 1302114824 at 1302114824 ---------------

Ok, quick update. There was an extra space in a bit of the code, so I removed that and now my signature gets saved again and I can still post links in the signature. So, now I need help trying to figure out what I need to add/edit/move to make it where users can't post links in their signatures until they reach a certain post count.

Thank you :)

Lynne
04-06-2011, 07:50 PM
So this isn't working?
$vbulletin->userinfo['posts'] < $vbulletin->options['usml_siglink_minposts']

Have you tried printing out those variables to see what is up with them?

HMBeaty
04-06-2011, 07:56 PM
So this isn't working?
$vbulletin->userinfo['posts'] < $vbulletin->options['usml_siglink_minposts']Have you tried printing out those variables to see what is up with them?
Well, I'm pretty sure that works, as I've used code very similar to that before, but other than that, I'm not sure what I'm doing wrong. As it is, I would think it should work just fine. :confused:

Lynne
04-06-2011, 08:00 PM
Right now, I look at your plugin and you are performing operations on the variable $pagetext. I thought you wanted to do stuff to the signature? Shouldn't that be a different variable name?

HMBeaty
04-06-2011, 08:03 PM
Right now, I look at your plugin and you are performing operations on the variable $pagetext. I thought you wanted to do stuff to the signature? Shouldn't that be a different variable name?
Now THAT is what I'm definately not sure of. Again, I pulled a couple of other modifications apart, basically combining them and reworking them, and ended up with this. So I'm not even sure which variable I need to use in place of that if anything at all...

--------------- Added 1302124353 at 1302124353 ---------------

Ok lol, I've tried:
$pagetext =& $this->fetch_field('signature', 'post');
and
$pagetext =& $this->fetch_field('updatesignature', 'post');
and
$pagetext =& $this->fetch_field('modifysignature', 'post');
And none of those seem to work, so apparently I'm still using the wrong variable lol

Eric
04-06-2011, 09:36 PM
Given the location of that hook, shouldn't you be able to use $signature ?

From profile.php:

// DO WYSIWYG processing to get to BB code.
if ($vbulletin->GPC['wysiwyg'])
{
require_once(DIR . '/includes/functions_wysiwyg.php');

$signature = convert_wysiwyg_html_to_bbcode($vbulletin->GPC['message'], $permissions['signaturepermissions'] & $vbulletin->bf_ugp_signaturepermissions['allowhtml']);
}
else
{
$signature = $vbulletin->GPC['message'];
}

($hook = vBulletinHook::fetch_hook('profile_updatesignature _start')) ? eval($hook) : false;

// handle image uploads


So, couldn't you use something like this:


$excludedugs = explode(',', $vbulletin->options['usml_siglink_exug']);

if (!is_member_of($vbulletin->userinfo, $excludedugs))
{
if ($vbulletin->options['usml_siglink_enable'] AND $vbulletin->userinfo['posts'] < $vbulletin->options['usml_siglink_minposts'])
{
if (stristr($signature, 'http://') OR stristr($signature, 'www.') OR stristr($signature, '[URL'))
{
$errors[] = fetch_error('usml_siglink_msg', $vbulletin->userinfo['username'], $vbulletin->options['usml_siglink_minposts'], $vbulletin->userinfo['posts']);
}
}
}

HMBeaty
04-06-2011, 10:10 PM
Given the location of that hook, shouldn't you be able to use $signature ?

From profile.php:

// DO WYSIWYG processing to get to BB code.
if ($vbulletin->GPC['wysiwyg'])
{
require_once(DIR . '/includes/functions_wysiwyg.php');

$signature = convert_wysiwyg_html_to_bbcode($vbulletin->GPC['message'], $permissions['signaturepermissions'] & $vbulletin->bf_ugp_signaturepermissions['allowhtml']);
}
else
{
$signature = $vbulletin->GPC['message'];
}

($hook = vBulletinHook::fetch_hook('profile_updatesignature _start')) ? eval($hook) : false;

// handle image uploads
So, couldn't you use something like this:


$excludedugs = explode(',', $vbulletin->options['usml_siglink_exug']);

if (!is_member_of($vbulletin->userinfo, $excludedugs))
{
if ($vbulletin->options['usml_siglink_enable'] AND $vbulletin->userinfo['posts'] < $vbulletin->options['usml_siglink_minposts'])
{
if (stristr($signature, 'http://') OR stristr($signature, 'www.') OR stristr($signature, '[URL'))
{
$errors[] = fetch_error('usml_siglink_msg', $vbulletin->userinfo['username'], $vbulletin->options['usml_siglink_minposts'], $vbulletin->userinfo['posts']);
}
}
}

I tried that too, but no luck

HMBeaty
04-06-2011, 10:25 PM
Here's the product if anyone wants to play around with it and let me know what you can come up with....

Just import. No file or template edits needed

Eric
04-06-2011, 10:36 PM
The code I posted works for me

127981

What I tried entering for the sig (without the spaces in the URL bbcode):

This is a [ url=http://test.com]test[/url ] - test.

HMBeaty
04-06-2011, 10:49 PM
Ok, yes, it works if you put in a regular url. Now, how do I make it so if a user tries to "go around" by using say....
vbulletin.comit would throw the same error. I figured I could do that with the
OR stristr($signature, '.com')part of the code, but no luck. Or is that even possible?

EDIT: Thank you for you help too

Eric
04-06-2011, 10:54 PM
You mean:


This is a [ url=vbulletin.com]test[/url ] - test.

Which still throws the error...

Or just the presence of a domain?


This is a test. vbulletin.com


Because the latter... it's going to be rough trying to block something like that, with all the possible combinations etc - that shouldn't be parsed into a URL anyway.

HMBeaty
04-06-2011, 10:57 PM
This is a test. vbulletin.com
Because the latter... it's going to be rough trying to block something like that, with all the possible combinations etc - that shouldn't be parsed into a URL anyway.
This. I'm also trying to make so if anyone uses
test.com
that it would reject that as well

Eric
04-06-2011, 11:05 PM
This appears to work:


$excludedugs = explode(',', $vbulletin->options['usml_siglink_exug']);

if (!is_member_of($vbulletin->userinfo, $excludedugs))
{
if ($vbulletin->options['usml_siglink_enable'] AND $vbulletin->userinfo['posts'] < $vbulletin->options['usml_siglink_minposts'])
{
if (
stristr($signature, 'http://') OR
stristr($signature, 'www.') OR
stristr($signature, '[URL') OR
preg_match("#[a-z0-9]([-a-z0-9]+)?(\.[a-z]{2,3})?(\.[a-z]{2,4})#i", $signature)
)
{
$errors[] = fetch_error(
'usml_siglink_msg',
$vbulletin->userinfo['username'],
$vbulletin->options['usml_siglink_minposts'],
$vbulletin->userinfo['posts']
);
}
}
}

HMBeaty
04-06-2011, 11:15 PM
This appears to work:


$excludedugs = explode(',', $vbulletin->options['usml_siglink_exug']);

if (!is_member_of($vbulletin->userinfo, $excludedugs))
{
if ($vbulletin->options['usml_siglink_enable'] AND $vbulletin->userinfo['posts'] < $vbulletin->options['usml_siglink_minposts'])
{
if (
stristr($signature, 'http://') OR
stristr($signature, 'www.') OR
stristr($signature, '[URL') OR
preg_match("#[a-z0-9]([-a-z0-9]+)?(\.[a-z]{2,3})?(\.[a-z]{2,4})#i", $signature)
)
{
$errors[] = fetch_error(
'usml_siglink_msg',
$vbulletin->userinfo['username'],
$vbulletin->options['usml_siglink_minposts'],
$vbulletin->userinfo['posts']
);
}
}
}

Awesome! You rock! Thank you! lol :D