Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Navigation
Latest Addons
Cookiebar Panel 5
AD Gallery 68
SyntaxHighlighte... 51
Newsletters v4.03 114
Facebook Like Box 135
Newsletters v4.02 60
Metro 173
Facebook Connect 174
Shoutbox Panel 131
Redactor for PHP... 107
MI Floating Side... 109
Facebook Login/R... 156
Avatar Studio v2.03 180
Relationship Sta... 98
Sexual Orientati... 116
Popular Addons
iTheme2 5810
Arise 5808
User Control v1.23 4624
Event Calendar 4055
Photowidget panel 3889
Radio-Theme red2... 3360
Highslide Gallery 3315
CSS/JavaScript D... 3234
Facebook Connect... 2992
Dynamic Menu 2895
Slideshow Lightb... 2729
L-AMANT 2662
Enigma 2637
2Dark 2608
Black 2580
View Thread
Who is here? 1 guest(s)
 Print Thread
Hooks System v1.0 - No more modifying core files!
firebun
Hi
Today I would like to release my Hook System but I wondering where I should put it?

It is not an infusion.
It is one file and a subdirectory with example files how to use it.

hooks.php - the main hook system

folder: hooks/

files in the hooks folder are for customizing your hooks.

This hooks system lets you create modifications and infusions without having to modify any core phpfusion files (mostly).

To make this system work you only need to add one line to maincore.php at the bottom and you are done and can start building your own hooks.

It is a very powerful system and it allows you to create actions before and after events by a user. For example you can have a hook that triggers an event after a user logs into your site. Maybe you want to send a message saying thanks for login or something. The sky is the limit.

Let me know where I should post this "addon".

Why build this hooks system?

I am working on a very large infusion and I did not want to modify core files.
My infusion is called "Members Rewards System". It is an all-in-one members rewards system. I've got large chunks of the code completed and working on finishing other pieces. Read the list of features and if you see anything that should be added or explained by all means let me know.

Here are some of the built in features and functionalities.

Hooks, Rules, Points, XP, Awards, Ranks, Pokes, Titles, Items/Gifts, Item Shop, Banking, Lotto, Robery, Random Adventure

Hooks: (the hook system I mentioned above)

Rules: Conditions that occur when specific events match a rule. Rules are used to trigger events.

Points: The points system. Just handles points. Making a new record for new users as well as giving and taking points based on the input you pass it.

XP: This tracks the lifetime total points (both positive and negative) of a user. Basically it is a transaction record of each time a point was given or taken as well as the timestamp and type of point (negative/positive) This information can be used in a fun way by using hooks and rules.

Awards: The awards consists of little 16pixel images that serve as awards given to users in an automated fashion for triggering certain events as defined by a rule.
It handles giving, taking awards based on the settings you choose in your rules.

Ranks: The rank adds ranks which serve as a rank of your standing in the digital community of your website. So for example, if you are very helpful or post usefull replies to topics, you perhaps trigger a rule that could for example occur when you receive 50 votes or 50 thank yous or 300 replies in a topic. In the rule that is triggered it can add or subtract your rank. You can have multiple ranks. They consist of text and image and you can choose to show one or the other.

Pokes : Adds pokes. Pokes are member to member micro messages. A member may choose to send a poke in exchange for a predetermined amount of points. Pokes may be set to free (0 points), this is defined in the settings. Pokes can be text or image (32x32 currently). You can have different types of pokes. War pokes, fun pokes, joke pokes, happy pokes, etc.

Titles: Titles adds titles like in guild wars. I stole the idea from there. Basically for performing a collection of events as defined in a rule you increase your title in relation to that event. For example you could have a title related to your forum called "Form Topics Posts" and you make a series of progressive titles for it and then you define a rule for each title. There is a setting to allow users to select one title to display in their profile across the site.
Forum Topic Posts:
- Newbie: Rule -> has between 0 and 10 posts
- New Member: Rule -> has between 11 and 50 posts
- Member: Rule -> has between 51 and 2000 posts
- Old Timer: Rule -> has between 2001 and 10000 posts
- Immortal: Rule -> has more than 10001 posts

Loves Writting Articles:
- Apprentice: Rule -> has less than 20 article posts with less than 5 possitive votes
- Writter: Rule -> has 50 article posts with more than 100 positive votes and 10 comments
- Master: Rule -> has 100 article posts and 10 news posts and 5 links all with at least 10 postitive votes and 3 comments

You build your rules. Its easy.


Items : Alone this doesn't do much visually but with the Item shop it is very handy. Items come in several flavors. Images, permissions, events and style tweaks. Items can be limited edition. They can trigger events, for example you could have an item that let the user change the color of their name.

Item Shop plugin: handles all inventory and sales. Add , edit or remove items from the shop. You can set the prices and rule for each item added. For example if you only wanted to show items of certain kind to a member with the Title of Newbie or a member who had a certain Award, you could.

Banking : If enabled, members can earn interest on points in your bank. THey can signup with the bank (you can define a point fee - weekly/monthly/etc). With the bank account they can deposit and withdraw points. You can configure all interest, fees, the name of the bank, etc.

Lotto : You configure the lotto frequency, the jackpot method to use and ticket point prices. Simple.

Robbery : You can allow members to rob other members. Configure the % of points taken in a successful robbery, the success rate and points lost for failure.

Random Adventure : Random one line strings of text with yes or no answers. Example: Before you lies a vast desert. Do you cross it? Yes/No. Randomly the script itself chooses the correct answer. If the user matches the script random answer then they user gets a configured amount points or triggers a rule. ANother example: You come across a room full of zombies. Kill them with your chainsaw? yes/no - a user picks yes and the script picked yes so this triggers a rule that gives the user a rare item from the item database (not something sold in the item shop).


And more.

The Member Reward System is still being worked and I am not sure when it will be released but before official release I will need beta tester, if your interested let me know.

Smile
 
gh0st2k
I'd like to see it, first of all, just attach it here Wink
Ex Senior Dev.
 
firebun
I am setting up a support site for this. I will post it shortly.
 
Falcon
Hello firebun,

Wow, thats really awesome, we started this for v8, please get to PHP-Fusion Next our development site.

I will notice our Lead Developer about this thread.

Good luck!
 
agx-media.net
Christian
That sounds amazing - any contributions are much appreciated. If you would like to contribute to PHP-Fusion core, please feel free to send an application or contact me directly.
Best regards,
Christian Damsgaard Jørgensen,
PHP-Fusion Lead Developer.
 
http://www.php-fusion.dk/
firebun
PMM wrote:

That sounds amazing - any contributions are much appreciated. If you would like to contribute to PHP-Fusion core, please feel free to send an application or contact me directly.


thanks, I signed up but never receive activation email
 
Christian
firebun wrote:
thanks, I signed up but never receive activation email

Sorry about that - I will make sure that the problem is addressed and get back Smile
Best regards,
Christian Damsgaard Jørgensen,
PHP-Fusion Lead Developer.
 
http://www.php-fusion.dk/
firebun
OK I have setup a site for my addons and infusions.

I will offer support for them on that site.

http://firebun.com

I am in the process of creating documentation and examples of how to use the Hooks. Please note that it is Easter weekend and I will be on and off due to family obligations during this time.

Happy Easter
Smile

Merged on Apr 07 2012 at 02:56:59:
I've posted a few examples with some explanation of how it works.

Also I updated the hooks.php because I forgot some variables that are used in comments and ratings. so download the hooks_system-v1.1c.rar archive.

How do I create new Hooks?

Example Hook - Points for Commenting on Article

Merged on Apr 07 2012 at 03:29:49:
Quick way to see what variables are available to a page

Merged on Apr 07 2012 at 03:57:22:
Simple forum example
Edited by firebun on 07-04-2012 03:57
 
PolarFox
Is it fast (parsing of the page with this)?
 
http://unlogic.info
firebun
PolarFox wrote:

Is it fast (parsing of the page with this)?


How server intensive is this?

The hooks.php file itself is takes up very little memory to process and is processed quickly. The base hooks.php without any hooks installed on my system executes in an average of 0.0002 seconds.

Execution time will change as you create hooks of varying complexity.
 
gh0st2k
This script is fast and simple, it just checks the incoming $_GET and $_POST vars. But it's not new, I think the current handling of using a panel to do this is better => you don't have to edit maincore.php or to use a fixed file name handling. You can also include it in every infusion (as a panel).

The most important thing is the documentation. You have to know which variables indicates which action.

You can do a lot of nice stuff with this kind of "hooks" and the output replacement, but it's nothing for v8. With functions and / or OOP you should be allowed to replace everything.
Ex Senior Dev.
 
firebun
Here is an example of a converted Infusion that required core modifications and so now it does not require core edits (99%). In this example I show how to use Hooks instead of modifying core files.

Converting an existing Infusion - PointX 1.0.3 by Yodix
 
gh0st2k
Yes, it is a way to prevent core changes... but this is also possible with panels, just copy your code in one of your hook files to a panel, which is active on every page => same effect.

There is just the need of a tutorial to explain it to every developer.

Anyway, it's nice that you try to enhance the development.
Ex Senior Dev.
 
firebun
gh0st2k wrote:

Yes, it is a way to prevent core changes... but this is also possible with panels, just copy your code in one of your hook files to a panel, which is active on every page => same effect.

There is just the need of a tutorial to explain it to every developer.

Anyway, it's nice that you try to enhance the development.


Perhaps I do not understand the Panel functionality but from what I can see in the system and how they function I must dissagree with you saying it is similar to Hooks.

From my understanding, panels must be active and execute in only 4 places (Left,Upper Center , Lower Center , Right) and if they are active their functions occur after the output of content begins intheir designated location.

The difference with the Hooks System is that you can manipulate content before the entire output is pushed to the client.

If Panels can do more, I would love to know how. Thanks in advance.
 
Tyler
I haven't tried this at all. I downloaded it and looked and was turned off to see $_REQUEST used for variables. Using $_REQUEST could be a mistake. $_REQUEST gathers $_GET, $_POST, and $_COOKIE data. If a cookie on anyones site had the same name as the variable the cookie value would over-ride. With something that will be used on any site I guess this could induce problems...

I'm not trying to take the wind out of your sail... Good job. Maybe I'd just stick with the panel method.....

Edit - Firebun, you are correct. The panels method does only work in relation to its position. However, maybe in the future fusion will support a panel zone specifically for this use and have it be before any content....
 
firebun
Mittens Returns wrote:

I haven't tried this at all. I downloaded it and looked and was turned off to see $_REQUEST used for variables. Using $_REQUEST could be a mistake. $_REQUEST gathers $_GET, $_POST, and $_COOKIE data. If a cookie on anyones site had the same name as the variable the cookie value would over-ride. With something that will be used on any site I guess this could induce problems...

I'm not trying to take the wind out of your sail... Good job. Maybe I'd just stick with the panel method.....

Edit - Firebun, you are correct. The panels method does on work in relation to its position. However, maybe in the future fusion will support a panel zone specifically for this use and have it be before any content....


The use of _REQUEST is entirely up to you and how you want to build your hooks.
If you prefer to use _GET _POST _HEADER etc, that is up to you.

Cheers
Cool
 
Tyler
You supply hooks. Those hooks use $_REQUEST. You obviously don't understand that your hooks would not work in several scenarios (specifically register activation). I really don't care about it I was just pointing it out.
 
Kot
firebun wrote:

To make this system work you only need to add one line to maincore.php at the bottom and you are done and can start building your own hooks.



OK, so what is the line to add?
 
firebun
Kot wrote:

firebun wrote:

To make this system work you only need to add one line to maincore.php at the bottom and you are done and can start building your own hooks.



OK, so what is the line to add?


as per the instructions
at the bottom of that file add:
Download source  Code
require('hooks.php');


 
Jump to Forum:
Similar Threads
Thread Forum Replies Last Post
[ADDON] Facebook Login/Register System Ideas for Modifications and Requests 43 17-04-2013 18:57
Secure Messaging System Official releases [Infusions] 3 25-02-2013 12:20
User Award System 2.0 Official releases [Infusions] 20 07-02-2013 11:28
Professional Download System Official releases [Infusions] 40 03-02-2013 22:00
Free 3rd Party Commenting System General Discussion 4 26-01-2013 08:54
Official Home of PHP-Fusion uses cookies. Some may already have been set. Read more about our Cookies here.
Please click the button I Consent Cookies to hide this bar and accept our cookies. If you continue to use the site with no action taken, we'll assume that you consent our cookies anyway.
Cookiebar Panel byVenue