Debt Consolidation - Infrared Sauna - Debt Consolidation - Magnetic Bead Bracelet - Top Game Tips

PDA

View Full Version : How to create a VB hack?


piniyini
Dec 2nd 2005, 12:29 pm
I'm not familiar with VB, only got my hands on it recently. I'm wanting to create a hack, with phpBB I know I had to change the php code and could have done something that way.

Now VB looks totally different, I heard that plugins could be created this way they still exist after an upgrade.

The hack I want to create has a simple logic, and that is to show the most recent member who has made a post in the "newest member" at the bottom of the page.

If it was phpBB I would added something like

WHERE posts > 0

to the source whereas with VB I dont know where to start. :confused:

digitalpoint
Dec 2nd 2005, 1:16 pm
You need to be more specific. :) Is "Newest Member" a sub-forum, or? What page do you want to show them on?

piniyini
Dec 2nd 2005, 1:29 pm
Newest member is on the main page at the bottom, y'know "Welcome to our new member, username". I want to show someone who has posted and not just registered

digitalpoint
Dec 2nd 2005, 1:46 pm
Make a plug-in with a hook location of forumhome_complete.

Query the data you want (I don't know the SQL query needed off the top of my head) and make the user name you want set to $newusername.

piniyini
Dec 2nd 2005, 1:59 pm
Oh f^*k, don't know eff all about this. Will go mess around with it and prolly watch it blow up in my face ...

Do I need to use OOP?

digitalpoint
Dec 2nd 2005, 2:11 pm
I haven't tested it, but this (as your PHP code for your hook) should work...

[Bad code clipped.]

digitalpoint
Dec 2nd 2005, 2:21 pm
Okay, that's wrong... I was close though. :) Forgot about query_first... anyway, here's the plug-in (you can just upload the XML file as a plug-in... NOT as a product).

piniyini
Dec 2nd 2005, 2:35 pm
I tried your first suggestion a few times, modifying it aswell to match the table name by adding the prefix and putting brackets in etc - was about to post that I cant get to work and saw your post.

Ah cant this to work either, uploaded it no problems, shows up in the plugin manager. All the code seems correct, eg table and field names.

I am thinking the VB source code needs changing because what we generate is probably replaced by thier code, no?

I dont know what else...

digitalpoint
Dec 2nd 2005, 2:36 pm
Hmmmm, it works for me...

I'll test it again when the newest user doesn't have a post. :)

piniyini
Dec 2nd 2005, 2:40 pm
Fuggity fugg, what a dopey dope I am.

Warning: Plugins are currently globally disabled in your options. In order for plugins and products to function correctly, you must enable the plugin system. Importing a product will do this for you automatically.

I assumed the last sentence there would switch it on, but no so have done it now and it works :) except the member?u= id is incorrect. Will look into it.

I'm telling ya, you are the BOMB ;)

digitalpoint
Dec 2nd 2005, 2:53 pm
Okay... use this plug-in (takes into account custom table prefixes and also the userid).

piniyini
Dec 2nd 2005, 3:00 pm
Cant get the userid to work on the url

this is what I got

$newusername = $db->query_first("SELECT userid, username FROM `PREFIXuser` WHERE (`posts` > 0) ORDER BY `userid` DESC LIMIT 1");
$newusername = $newusername['username'];
$newuserid = $newusername['userid'];

digitalpoint
Dec 2nd 2005, 3:01 pm
See my previous post. :)

piniyini
Dec 2nd 2005, 3:09 pm
*Must remember to refresh before posting*

Excellent, its all working now!

How come the one I did didn't work? Is it because I had the userid as the last line instead of the username?

And how do you know so much about VB, like what to name the variables? I wouldnt know where to start.

This was my first shot at the plugin thingy and from my first experiance doesnt seem extremely difficult.

digitalpoint
Dec 2nd 2005, 3:14 pm
The one you did didn't work because I was reusing a variable. You ended up destroying the array with the userid in it before you got it (was just execution order).

I just look at the PHP source code to figure out the hook name and variables. For example if you look towards the end of the main file (index.php), you can see the variable names and hook name.

So for simple things like that it's no biggie.

piniyini
Dec 2nd 2005, 3:42 pm
The one you did didn't work because I was reusing a variable. You ended up destroying the array with the userid in it before you got it (was just execution order).

I seriously need to get a book on PHP. Dont understand what you mean there, the only difference I am seeing is the $newuserid being fetched before $newusername.

I've swapped these two lines around just to test and realised it only works when $newuserid is first.

I see what you mean by variable names, I might aswell comment them out in index.php (right?) because this way those two queries are running when there is no need.

Promise I'll stop asking questions after this one ;)

digitalpoint
Dec 2nd 2005, 3:50 pm
No point in commenting them out in the PHP file... They don't require a query to begin with so the overhead of setting a variable wouldn't even be measurable. Plus the point of plug-ins is so you don't have to edit your PHP files.

piniyini
Dec 2nd 2005, 4:03 pm
No point in commenting them out in the PHP file... They don't require a query to begin with so the overhead of setting a variable wouldn't even be measurable. Plus the point of plug-ins is so you don't have to edit your PHP files.

Now this really is something. Ok I'll stop now, thanks ever so much Shawn ;)

joeychgo
Dec 3rd 2005, 7:50 pm
No point in commenting them out in the PHP file... They don't require a query to begin with so the overhead of setting a variable wouldn't even be measurable. Plus the point of plug-ins is so you don't have to edit your PHP files.


Exactly - which makes upgrading to a new version EASY