1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to create a VB hack?

Discussion in 'Forum Management' started by piniyini, Dec 2, 2005.

  1. #1
    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
    Code (markup):
    to the source whereas with VB I dont know where to start. :confused:
     
    piniyini, Dec 2, 2005 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    You need to be more specific. :) Is "Newest Member" a sub-forum, or? What page do you want to show them on?
     
    digitalpoint, Dec 2, 2005 IP
  3. piniyini

    piniyini Well-Known Member

    Messages:
    514
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    170
    #3
    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
     
    piniyini, Dec 2, 2005 IP
  4. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #4
    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.
     
    digitalpoint, Dec 2, 2005 IP
  5. piniyini

    piniyini Well-Known Member

    Messages:
    514
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    170
    #5
    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?
     
    piniyini, Dec 2, 2005 IP
  6. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #6
    I haven't tested it, but this (as your PHP code for your hook) should work...

    [Bad code clipped.]
     
    digitalpoint, Dec 2, 2005 IP
  7. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #7
    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).
     
    digitalpoint, Dec 2, 2005 IP
  8. piniyini

    piniyini Well-Known Member

    Messages:
    514
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    170
    #8
    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...
     
    piniyini, Dec 2, 2005 IP
  9. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #9
    Hmmmm, it works for me...

    I'll test it again when the newest user doesn't have a post. :)
     
    digitalpoint, Dec 2, 2005 IP
    piniyini likes this.
  10. piniyini

    piniyini Well-Known Member

    Messages:
    514
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    170
    #10
    Fuggity fugg, what a dopey dope I am.

    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 ;)
     
    piniyini, Dec 2, 2005 IP
  11. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #11
    Okay... use this plug-in (takes into account custom table prefixes and also the userid).
     

    Attached Files:

    digitalpoint, Dec 2, 2005 IP
    GuyFromChicago likes this.
  12. piniyini

    piniyini Well-Known Member

    Messages:
    514
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    170
    #12
    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'];
    PHP:
     
    piniyini, Dec 2, 2005 IP
  13. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #13
    See my previous post. :)
     
    digitalpoint, Dec 2, 2005 IP
  14. piniyini

    piniyini Well-Known Member

    Messages:
    514
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    170
    #14
    *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.
     
    piniyini, Dec 2, 2005 IP
  15. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #15
    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.
     
    digitalpoint, Dec 2, 2005 IP
  16. piniyini

    piniyini Well-Known Member

    Messages:
    514
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    170
    #16
    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 ;)
     
    piniyini, Dec 2, 2005 IP
  17. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,333
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #17
    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.
     
    digitalpoint, Dec 2, 2005 IP
  18. piniyini

    piniyini Well-Known Member

    Messages:
    514
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    170
    #18
    Now this really is something. Ok I'll stop now, thanks ever so much Shawn ;)
     
    piniyini, Dec 2, 2005 IP
  19. joeychgo

    joeychgo Notable Member

    Messages:
    3,368
    Likes Received:
    321
    Best Answers:
    0
    Trophy Points:
    255
    #19

    Exactly - which makes upgrading to a new version EASY
     
    joeychgo, Dec 3, 2005 IP