vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   How do I convert my "hack" to a plugin / addon??? (https://vborg.vbsupport.ru/showthread.php?t=129448)

Dr00pY 10-19-2006 06:08 AM

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

Paul M 10-19-2006 07:07 AM

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



Dr00pY 10-19-2006 03:31 PM

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

Reeve of shinra 10-19-2006 04:22 PM

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.

Dr00pY 10-19-2006 07:28 PM

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 https://vborg.vbsupport.ru/","",$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

3CS 10-20-2006 11:31 AM

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:


All times are GMT. The time now is 05:04 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.01030 seconds
  • Memory Usage 1,731KB
  • 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
  • (2)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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