Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-19-2006, 06:08 AM
Dr00pY Dr00pY is offline
 
Join Date: Jun 2006
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How do I convert my "hack" to a plugin / addon???

Ok, I have the need to hack my code so that I can regulate who uses the [ img ] tag. My code goes in the newreply.php. I still need to fully test it, and I know I still need to edit additional files to make my change complete. Just stating this, before anyone lets me know my hack doesn't work. Its not done.

Anyways.....here is what I have done....

I have inserted the following code at about line 301

Code:
        // If user primary group is not 6,7 or 17....remove the img tags
        $tmp = $vbulletin->db->query_first("
                SELECT count(1) as num
                FROM " . TABLE_PREFIX . "user AS user
                WHERE user.userid = " . $vbulletin->userinfo['userid'] . " AND
                        user.usergroupid in (6,7,17)
        ");
        if (0 == $tmp['num'])
        {

                //we need to remove the [img] tags....
                $newpost['message'] = str_ireplace("[img]","",$newpost['message']);
                $newpost['message'] = str_ireplace("[/img]","",$newpost['message']);

        }
Now lets say that was it. My whole hack was just this piece of code. How do I then move this out of the vb code and into a plugin / addon / product.

I tried looking at some examples, but most of those where template changes.


Thanks for your help,


Dr00pY
Reply With Quote
  #2  
Old 10-19-2006, 07:07 AM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You need to find the nearest hook call in the file, which in this case appears to be "newreply_post_start", a few lines above. Then you need to write it so it will work at that point in the file (which in this case means you need to edit $vbulletin->GPC['message'] as it's not yet assigned to $newpost['message']. Then you create the plugin in the APC Plugin manager.

BTW, that's a terrible way to check if a user is in those primary user groups, just use ;
PHP Code:
if in_array($vbulletin->userinfo['usergroupid'], array(6,7,17)) 
{
//do something

Reply With Quote
  #3  
Old 10-19-2006, 03:31 PM
Dr00pY Dr00pY is offline
 
Join Date: Jun 2006
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I knew there was an easy way to do that...just didn't know what it was. Thank you so much...ok so these "hooks" are the key....time to look into that....

Thank you again....

Dr00pY
Reply With Quote
  #4  
Old 10-19-2006, 04:22 PM
Reeve of shinra's Avatar
Reeve of shinra Reeve of shinra is offline
 
Join Date: Oct 2001
Location: NYC
Posts: 1,896
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You may already know this but go to admincp->something I cant remember-> Products and create a new product.

When you add your phrases and your plugins, you can associate them with the product for easy export/import.
Reply With Quote
  #5  
Old 10-19-2006, 07:28 PM
Dr00pY Dr00pY is offline
 
Join Date: Jun 2006
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you all for the help....I think I got what I wanted done....

In case anyone else wants to do something similar....this is the code i'm using

Code:
if (!in_array($vbulletin->userinfo['usergroupid'], array(6,7,17)))
{ 
	//we need to remove the ","",$vbulletin->GPC['message']);
}
I created 3 plugins with the above code at:

editpost_update_start
newreply_post_start
newthread_post_start

You will ofcourse have to change the 6,7,17 to whatever groups you wish to give img access to.

I still need to fully test everything, but as far as I can tell, that basically does everything I needed to do. And let me say WOW. I was afraid of creating a huge hack job of the code that would be very difficult to maintained. Instead I ended up with a set of plugins that make adding and modifing them easy, and will almost likely never affect any updates. I'm so happy I'm switching to VB for this reason alone......

Thanks again for the help...and if anyone knows if I missed any other place to put this code in, I would greatly appreciate it...


Dr00pY
Reply With Quote
  #6  
Old 10-20-2006, 11:31 AM
3CS 3CS is offline
 
Join Date: Aug 2006
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think this is a similar question so rather than start a new thread...

I have some working php code that I don't know how to incorporate into my forum. Just under my banner I want some php code to write out some javascript - one of 2 scripts will run and the php chooses one randomly :

PHP Code:
<?
$random_url = array("http://www.tickermyfeed.com/feed.php?HRMV8tbSD0", "http://www.tickermyfeed.com/feed.php?P2JveHdpZHRoP");
srand(time());
$random = (rand()%2);
print("<script language=\"javascript\" src=\"$random_url[$random]\"></script>");
?>
The real http addresses there are miles long so I've abbreviated them.
I was hoping to just add this php code in under the Admin CP, "Common Templates > header".
What exactly do I need to do to make this work?
I've just read various tutorials but can't see what I need.

Thanks in advance for any ideas :up:
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:37 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04159 seconds
  • Memory Usage 2,214KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete