PDA

View Full Version : Hooks Manager v2


Zero Tolerance
06-09-2005, 10:00 PM
Well as the vBulletin are request extra hook locations, i find it very hard that they would be able to forfill everyones request, because if they did the php files would mostly contain hook calls, so to ease the pain of adding you're own hooks manually, i have created this addon, to add/edit/delete your own hooks using the acp! :)

Features:

Adding A Custom Hook

Hook Category
Hook Name
Choose ANY PHP file in your forums directory to place the hook (including sub-fodlers)
Insert a line of PHP from the specified file to designate where the hook will be placed
Choose to locate the hook above or below the specified line of PHP
Will automatically modify your PHP file AND vbulletin_hooks.xml for you.
View file contents : Will automatically show the contents of the PHP file, so you can choose where to place the hook.

Modifying A Custom Hook

Change any details you inputted while creating the custom hook
Any plugins assigned to it will be moved to the edited version (if the hook name is changed)

Deleting A Custom Hook

Removes all file edits for that specific hook
Deletes all plugins assigned to that hook location

Repairing All Custom Hooks

Repairs all custom hooks : This is designed to keep your custom hooks intact, if you accidently overwrite any file with a custom hook or vbulletin_hooks.xml, or if you've just upgraded your vBulletin forum, the repair function will re-insert ALL custom hooks back onto your system, with no manual file modifications required.

Export Custom Hook Locations To Auto Installer

The custom hooks exporter is aimed at developers, and will automatically create an install file for people to use and run on there server, the intention is that you export custom hook locations for people to install so that your own modification runs off these hook locations. Please ensure that you notify users installing any modifications you provide with a custom hooks export installer to run the custom hooks installer first before proceeding to import any plugins!.
Installer Includes: Installer/Uninstaller/Repairer for all custom hook locations exported inside it.




File edits: 3 (admincp/plugin.php & includes/xml/cpnav_vbulletin.xml)
Requirements: CHMOD all php files in your forums directory (including sub folders) to 0666, and includes/xml/hooks_vbulletin.xml to 0666 (Will not function without this done!)


Enjoy :)

- Zero Tolerance

Paul M
06-10-2005, 02:51 AM
Whose been busy then :) I'll be giving this a tryout at some point.

Presumably if you upgrade your vB, you need to add all the custom hooks again - does this keep a record of the ones you have added ?

Zero Tolerance
06-10-2005, 02:54 AM
Whose been busy then :) I'll be giving this a tryout at some point.

Presumably if you upgrade your vB, you need to add all the custom hooks again - does this keep a record of the ones you have added ?
The XML file keeps a record of all custom hooks, like the default vB system does, in the next version it will "fully" support other xml files, as vBulletin built in the ability to have multiple hook xml files, however mine doesn't "fully" work with that and relies on the master one given by vB, so i'll ensure it's running through it's own so upgrades shouldn't effect anything, unless a PHP file is re-uploaded, then a hook would need to be re-done, i'll create a lil system for this which will check all the hook calls are in the files, and if not, add them in.

Once that's done really, no one would need to bug vB anymore for hook locations :)

- Zero Tolerance

Andreas
06-10-2005, 03:18 AM
Once that's done really, no one would need to bug vB anymore for hook locations :)

Hmm .... not really. If you are using custom hooks you must edit the PHP files, if there are standard hooks you can easily upgrade without having to re-apply file modificatiosn.

Zero Tolerance
06-10-2005, 03:20 AM
Hmm .... not really. If you are using custom hooks you must edit the PHP files, if there are standard hooks you can easily upgrade without having to re-apply file modificatiosn.
This edits them for you, and the repair system i'm including will correct all custom hook installations if you have just upgraded your vB :)

- Zero Tolerance

Andreas
06-10-2005, 03:22 AM
Hmm, this is like vBHack - a system that automatically alters your PHP files.
Don't like the idea too much ...

Paul M
06-10-2005, 03:23 AM
i'll create a lil system for this which will check all the hook calls are in the files, and if not, add them in.how would it know where to add them - line numbers are bound to change.

Zero Tolerance
06-10-2005, 03:24 AM
True, but it's only altering 1 line (for each hook), the only way it could mess up your system was if you inserted a hook onto a line where it should be, like inbetween if() and {, ofcourse you can delete the hook if errors occur (once i get the next release done).

@ Paul - That's upto you to keep things updated, the PHP will change over time, so it would be best to keep the hooks updated and ensure there in a safe place, if there nested inside a lot of code, chances are in the future it would cause problems, but if it's out of the way in a distant area, then the chance is smaller. Unfortunatly there isn't much i can do about this, even if you put in a search term to insert the hook after/below, the PHP again could be changed within the future.

- Zero Tolerance

Link14716
06-10-2005, 03:27 AM
Here's the main problem: line numbers change.

Zero Tolerance
06-10-2005, 03:28 AM
Here's the main problem: line numbers change.
Then feel free to give me an alternate method that would eradicate that problem and not cause any others - i'm all ears =P

- Zero Tolerance

Andreas
06-10-2005, 03:31 AM
If there was an easy solution, there would have been an automatic patch system since ages I guess :)

Zero Tolerance
06-10-2005, 03:43 AM
Well, i have an idea, which is not flawless, however not as flawed as the line number. Have an area to input code, then choose to place the hook before/after the code, ofcourse the code may be changed in the future, so being very specific instead of inserting a huge lump of code would improve the ratio of succession, and if it was only the line number changed, it won't matter.

- Zero Tolerance

Brent H
06-10-2005, 03:56 AM
Why not have it show the contents of the PHP file, and a radio button next to each line. You select the line you want, and then chose "Above This Line" or "Below This Line".

Not sure if something like that is possible but hey, it's just an idea :)

zetetic
06-10-2005, 04:07 AM
Hmm... if you have to open the file to determine where you're going to insert the hook, why not just add it then instead of going back to the ACP?

Zero Tolerance
06-10-2005, 04:15 AM
Hmm... if you have to open the file to determine where you're going to insert the hook, why not just add it then instead of going back to the ACP?
You also need to modify vbulletin_hooks.xml or another hook xml file to create a hook location, so when you go to Add A Plugin, you will be able to see the hook location you added :)

The point of this is to eradicate manualy coding in the hooks.

- Zero Tolerance

Erwin
06-10-2005, 04:26 AM
Whatever the problems with this, it's a good idea. :)

spooler
06-10-2005, 10:46 AM
Really nice idea ZT to manage custom hooks :claps: .

Just a suggestion if u like.

Basically a coder requires 3 things :-
1> To add more code in files
2> To remove existing code
3> To replace existing code

Your hack manages the 1st point very well but most of the mods cant work without 2&3.

If along with custom hooks, you could add custom comments like

/* Zero Tolerance comment

######Existing code here ########

Zero Tolerance comment */

Custom commenting will help remove the existing code.Also to replace the code, a custom hook(with the replaced code) can be placed just above or below the custom comments. Also you can keep track of custom hooks+comments together by parsing the file or just storing the line numbers.

Although this all can be done manually but it will be a more organised approach to manage it with your hack instead of going through file and doing ctrl+f.

More functionalities can be added to it like cleanup file which can remove all custom comments and hook for debugging etc.

Just my thought on the fly :D

Svenna
06-11-2005, 02:02 PM
nice job :nervous:

Zero Tolerance
06-12-2005, 09:15 PM
Nice suggestions spool, however point 2 & 3 may be useful, it is not the point of this modification, which is to create custom hooks, not to change the vB code for modifications, the idea is you have a modification, but the hooks you want do not exist, so you create them using this, so then you can add the plugins to your newly created hook.

Sorry for the delay on v1, i was out shopping o_o (Bad excuse - i know).

Should be completed within the next hour or 2 :)

- Zero Tolerance

Zero Tolerance
06-12-2005, 11:52 PM
v1 has been released, look uptop for features, if you used the old version, you must delete all custom hooks you added with the old system before proceeding to upgrade.

- Zero Tolerance

eXtremeTim
06-13-2005, 12:34 AM
I can honestly say that what me and zt have been talking about sounds amazing. I know all my hacks will use this system to avoid file edits.

Dream
06-13-2005, 12:42 AM
this is creepy, but ill test it out, running a test forum anyway

eXtremeTim
06-13-2005, 02:39 AM
wait till you see the next version. ;)

Zero Tolerance
06-13-2005, 04:54 AM
v2 released, this is what eXtremeTim gave me the idea about and was excited about :p

The custom hooks exporter is aimed at developers, and will automatically create an install file for people to use and run on there server, the intention is that you export custom hook locations for people to install so that your own modification runs off these hook locations. Please ensure that you notify users installing any modifications you provide with a custom hooks export installer to run the custom hooks installer first before proceeding to import any plugins!.

Enjoy :)

- Zero Tolerance

eXtremeTim
06-14-2005, 03:49 PM
I can tell you this so far this hack looks great.

Frenck
06-17-2005, 09:44 AM
The button 'Show File Contents' seems not to work in firefox.


A second one.... I want to add a hook in includes/class_bbcode.php


function handle_bbcode_code($code)
{

// THIS IS THE PLACE WHERE I WANT A HOOK....


global $vbulletin, $vbphrase, $stylevar, $show;

// remove unnecessary line breaks and escaped quotes
$code = str_replace(array('<br>', '<br />', '\\"'), array('', '', '"'), $code);

$code = $this->strip_front_back_whitespace($code, 1);

// fetch height of block element
$blockheight = $this->fetch_block_height($code);

$template = $this->printthread ? 'bbcode_code_printthread' : 'bbcode_code';
eval('$html = "' . fetch_template($template) . '";');
return $html;
}



How to create one with your plugin? I can't specify only '{' as the line to add the hook below, how to do this nicely?

May you have to expand your option to put a hook not online above or below a specified php line, but maybe also 2, 3, 4, 5 lines above or below...

FASherman
06-17-2005, 03:13 PM
After some long thought on this, I'd like to make a proposal to all the entire vb.com community to make allour lives easier.

1. Only hacks that require changes to sql queries should be hacks.

2. Take THIS hack and place it in a seperate forum calls "Add-on Hooks". When a someone codes a hack that can't use a standard hook, they add an add-on hook into this forum. Then they can release their hack as a plug-in. One the add-on hook is released, it can be used by anyone. It becomes an unoffical extension of VB.

3. In the description for plugins, add an additional 2 fields:
Requires add-on hook (y/n)
ThreadID of Add-on Hook.

4. The folsk at VB.Com now have a way to see how many plugins use these add-on hooks. If we have an add-on hook that is used by 20 or more hacks, they know that it should be incorporated into the next release. As they do so, then that add-on hook can be removed from the forum and the hacks updated as full-plugin without add-on hooks.

5. For those of us with hacked boards, all it means is that we have to reinstall our hooks, not the entire hack.

Comments/questions/concerns?

Ron1n
06-17-2005, 10:21 PM
i am in love - this hack is great

macooper
06-27-2005, 06:31 AM
Hi,
I'm not sure how well this would work, but when patching the linux kernel, they use something called context diffs. Could this be adapted for this mod ?

The idea is that when you add a new hook, your system would take say 10 lines of code before and 10 lines after the hook location. When an upgrade is performed, any hooks in code that has not changed would be easily detected. However, if the 10 lines above / below the code have changed, then you would know that the hook needed redoing manually.

On applying the hooks to an upgraded board, you could then generate a list of failed patches that would need to be added manually. Not perfect, I know, but it would pick up the majority of failed hooks.

Martin

thermz
08-13-2005, 12:40 PM
Wow, exceeded yourself again.

dwh
08-15-2005, 04:53 AM
After some long thought on this, I'd like to make a proposal to all the entire vb.com community to make allour lives easier.

1. Only hacks that require changes to sql queries should be hacks.

2. Take THIS hack and place it in a seperate forum calls "Add-on Hooks". When a someone codes a hack that can't use a standard hook, they add an add-on hook into this forum. Then they can release their hack as a plug-in. One the add-on hook is released, it can be used by anyone. It becomes an unoffical extension of VB.

3. In the description for plugins, add an additional 2 fields:
Requires add-on hook (y/n)
ThreadID of Add-on Hook.

4. The folsk at VB.Com now have a way to see how many plugins use these add-on hooks. If we have an add-on hook that is used by 20 or more hacks, they know that it should be incorporated into the next release. As they do so, then that add-on hook can be removed from the forum and the hacks updated as full-plugin without add-on hooks.

5. For those of us with hacked boards, all it means is that we have to reinstall our hooks, not the entire hack.

Comments/questions/concerns?

Not bad idea.

akanevsky
10-09-2005, 01:24 AM
Just a suggestion:
Make this hack export XML files that would define what files should be edited and where. Then make a separate hack that would import those XML files.
Reason: so that people who install the hack would have an easier way of doing so.
:)

If there was an easy solution, there would have been an automatic patch system since ages I guess
There actually is an easy solution, and I have no idea why this is not done yet... Patch system should have been created long ago, as it is easy to make... As long as, of course, as there is a stable server that never has any bugs or hangouts while accessing files.

Mythotical
11-12-2005, 07:44 PM
Nevermind, works great.

futuredood
06-28-2006, 03:04 PM
can anyone confirm if this this works with 3.5.4?