PDA

View Full Version : [HTL] Addon: Auto-populate NavBar popup menu [for Erwin's Flash Player]


Natch
01-22-2004, 10:00 PM
Addon: Auto-populate NavBar popup menu [for Erwin's Flash Player]
Version: 1.2
vB-version: 3.0.0 Release Candidate 3
Developer: Natch
Install difficulty: Easy-as
File edits: 2
Template edits: 2

Description of the Hack:
This takes all your Flash Games you have uploaded into the /forums/games/ folder, and parses them into an array, then creates a vB3 (so cool) drop-down menu, and populates that menu with nicely-labelled links to every one of your games (provided they have the extension .swf.


HACK INSTALLATION DETAILS:
Files modified for this Hack:
global.php
includes/functions.php

Templates modified for this Hack:
navbar


NOTE: In attachment are both HTL and text instructions.

Pop the HTL file and the XML file into your htlfiles folder (remember to ensure the htl file is uploaded as BINARY) and run it thru the HTL, or read the text file and DIY :)

Enjoy! and props to Erwin for his great work ...


UPDATE: 1.2 Upgraded to HTL format.

UPDATE: 1.1 Added a script to format visible link names more neatly.

RELEASE: 1.0 Initial vB.org release.

CdaKnight
01-23-2004, 03:27 AM
I have a question. Is there any way that you can use the swfs array to populate another array, where you can tell it to use titles, etc via switch?

So like it goes through the swfs array and as it populates, it runs it through a switch to determine a Formal title for the file, like blaster.sfw becomes Blaster

Is that possible? I think it would make the hack more credible (although that's a great job done already!), and it would make the forums using it more professional. I don't have enough knowledge in PHP to even begin thinking about how to do it... so this is just a suggestion/request I guess. :)

Thanks again! I'm going to install this weekend regardless.

Chris

Natch
01-23-2004, 03:30 AM
I have a question. Is there any way that you can use the swfs array to populate another array, where you can tell it to use titles, etc via switch?

So like it goes through the swfs array and as it populates, it runs it through a switch to determine a Formal title for the file, like blaster.sfw becomes Blaster

Is that possible? I think it would make the hack more credible (although that's a great job done already!), and it would make the forums using it more professional. I don't have enough knowledge in PHP to even begin thinking about how to do it... so this is just a suggestion/request I guess. :)

Thanks again! I'm going to install this weekend regardless.

Chris
In short - yes :)

Done @ 5:05PM +10GMT 23-01-2004

:)

Bob
01-23-2004, 07:14 PM
Nice Job Natcher!!! :D

Allan
01-23-2004, 08:32 PM
it's compatible RC3 ?

Natch
01-23-2004, 08:35 PM
it's compatible RC3 ?
Not tested with RC3, but unless the upgrade does some major modifications to the navbar, it's highly likely it will work just fine.

Fi_InCogNiTo
01-24-2004, 01:52 PM
When I enter the following into global.php on RC3 my forum comes up as a blank white page. When I remove this line, the forum loads fine. It still doesn't fetch the games though:

$nav_flash = genFlashMenu($flashdir);

Natch
01-24-2004, 11:40 PM
When I enter the following into global.php on RC3 my forum comes up as a blank white page. When I remove this line, the forum loads fine. It still doesn't fetch the games though:

$nav_flash = genFlashMenu($flashdir);
Did you:

a) Edit the path to your forums in the line above this one and
b) make all the other alterations as well ?

The only reason this line will actually do anything is if you also have made the additions to the includes/functions.php file, and added the approriate changes to the navbar template.

Natch
01-26-2004, 12:04 AM
it's compatible RC3 ?
I just upgraded to RC3, and no probs at all ...

This hack-addon is RC3 compatible.

Natch
01-27-2004, 12:17 PM
Updated to HTL version: text file instructions still retained for DIY-ers.

CdaKnight
01-27-2004, 07:50 PM
When I tried to load in the HTL version, I got a database error...

I went to "Install Hack" via the HTL, and chose the "Auto-Populate Navbar popup menu [for Erwin's Flash Player]" from the list. Then I hit the confirm button, and it wasn't happy. Any ideas?


Database error in vBulletin 3.0.0 Release Candidate 3:

Invalid SQL: INSERT INTO hacklog (hacklogid, hackid, modname, modtype, linenumber, changetype, userid, oldcode, newcode, dateline, lastmodified, notes) VALUES ('', 1, 'navbar', 1, 0, 1, 283, '<!-- / NAVBAR POPUP MENUS -->
', ' <if condition=\"$show[\'member\']\"> // remove this line and the endif if you wish all users and guests to view the menu
<!-- flash player auto-menu -->
<div class=\"vbmenu_popup\" id=\"flashplayer_menu\" style=\"display:none\">
<table cellpadding=\"4\" cellspacing=\"1\" border=\"0\">

<tr><td class=\"thead\">$vbphrase[flashplayer_title]</td></tr>
$nav_flash
</table>
</div>
<!-- / flash player auto-menu -->
</if>
', 1075184306, 1075203260, ''), ('', 1, 'navbar', 1, 0, 1, 283, ' <if condition=\"$show[\'searchbuttons\']\">
<td class=\"vbmenu_control\"><a href=\"$vboptions[bburl]/search.php?$session[sessionurl]do=getnew\">$vbphrase[new_posts]</a></td>
<td id=\"navbar_search\" class=\"vbmenu_control\"><a href=\"$vboptions[bburl]/search.php?$session[sessionurl]\">$vbphrase[search]</a> <script type=\"text/javascript\"> vbmenu_register(\"navbar_search\"); </script></td>
</if>
', ' <if condition=\"$show[\'member\']\">
<td id=\"flashplayer\" class=\"vbmenu_control\"><a href=\"#flashplayer\">$vbphrase[flashplayer_title]</a> <script type=\"text/javascript\"> vbmenu_register(\"flashplayer\"); </script></td>
</if>
', 1075184306, 1075203260, ''), ('', 1, 'includes/functions.php', 0, 0, 1, 283, '/*================================================= =====================*\\
|| ################################################## ##################
|| # Downloaded: 20:02, Wed Jan 21st 2004
|| # CVS: $RCSfile: functions.php,v $ - $Revision: 1.934 $
|| ################################################## ##################
\\*=============================================== =======================*/
?>
', 'function genFlashMenu($flashdir) {
global $vboptions;
$swfarray = getInstalledGames($flashdir);
foreach ($swfarray as $filename) {
$playvar = substr($filename, 0, strpos($filename,\".\"));
$displayname = properCase($playvar);
$flashmenu.= \"\\t\\t<tr><td class=\\\"vbmenu_option\\\"><a href=\\\"$vboptions[bburl]/flash.php?play=\".$playvar.\"\\\">$displayname</a></td></tr>\\n\";
}
return $flashmenu;
}
function getInstalledGames($flashdir) {
$dh = opendir( $flashdir );
while( false !== ($file = readdir( $dh ))) {
// look for these file types....
if (eregi(\"(swf)$\",$file)) {
$swfs[] = $file;
}
}
return $swfs;
}
function properCase($text) {
$firstLetter = substr($text,0,1);
$rest = substr($text,1,strlen($text));
$spitout = strtoupper($firstLetter).$rest;
return $spitout;
}
', 1075184209, 1075203260, ''), ('', 1, 'global.php', 0, 0, 1, 283, '/*================================================= =====================*\\
|| ################################################## ##################
|| # Downloaded: 20:02, Wed Jan 21st 2004
|| # CVS: $RCSfile: global.php,v $ - $Revision: 1.240 $
|| ################################################## ##################
\\*=============================================== =======================*/
?>
', ' $flashdir = \'/full path to your/forums/games/\'; // alter this variable to match your forum setup
$nav_flash = genFlashMenu($flashdir);
', 1075184209, 1075203260, '<span style=\'font-size:larger\'><b>NOTE</b>: you MUST alter the path variable <b>$flashdir</b> here to match your forum setup.</span>')
mysql error: Unknown column 'changetype' in 'field list'

mysql error number: 1054

Date: Tuesday 27th of January 2004 01:37:35 PM
Script: http://*/hackadmin.php
Referer: http://*/hackadmin.php
Username: Atwookie
IP Address: *.*.*.*

Natch
01-27-2004, 08:37 PM
Well the error is referring to the hacklog table, saying mysql error: Unknown column 'changetype' in 'field list'

mysql error number: 1054 so I'll take this up to KuraFire ...

Q: had you removed all alterations from your manual install ?

[and can you edit your post to use {php} or {code} tags - that would make sure this entry full of hack-modifications is displayed properly ...]

KuraFire
01-27-2004, 08:45 PM
When I tried to load in the HTL version, I got a database error...

I went to "Install Hack" via the HTL, and chose the "Auto-Populate Navbar popup menu [for Erwin's Flash Player]" from the list. Then I hit the confirm button, and it wasn't happy. Any ideas?

[quote]
Database error in vBulletin 3.0.0 Release Candidate 3:

Invalid SQL: INSERT INTO hacklog (hacklogid, hackid, modname, modtype, linenumber, changetype, userid, oldcode, newcode, dateline, lastmodified, notes) VALUES
[ .... ]
mysql error: Unknown column 'changetype' in 'field list'

mysql error number: 1054
Very strange... does your table `hacklog` on your database have the column 'changetype' ??

KuraFire
01-27-2004, 08:47 PM
Very strange... does your table `hacklog` on your database have the column 'changetype' ??
Actually, now that I look at it I'm somewhat concerned...

the query says to insert these file/template modifications to hackid=1, but that one is reserved for the HTL itself...


*so confused*

*so scared that he had a major f*ckup in his script* :'(((

CdaKnight
01-27-2004, 09:06 PM
I don't have that column, although now I'm guessing I should... I used the installer... Is it possible to just drop 'hack' and 'hacklog' and run the installer to add them again (I'm assuming I wouldn't need the phrases, etc. again [including the file changes])

Kura, if you'd like to access my admincp, or need a copy of the files, please let me know what you need and I'll PM it to you.

And I could have sworn I installed the upgrade... and I'll check again and make sure I did it correctly. I'm normally not this incompetent with this stuff...

Oh, and PS: I never had a manual install. I chose to wait due to time constraints, and was very happy when you release the HTL version, saving me time.

Natch
01-27-2004, 09:27 PM
Actually, now that I look at it I'm somewhat concerned...

the query says to insert these file/template modifications to hackid=1, but that one is reserved for the HTL itself...


*so confused*

*so scared that he had a major f*ckup in his script* :'(((
It would only insert to hackid 1 if the HTL wasn't properly installed isn't that rite Kura ?

KuraFire
01-27-2004, 10:16 PM
I don't have that column, although now I'm guessing I should... I used the installer... Is it possible to just drop 'hack' and 'hacklog' and run the installer to add them again (I'm assuming I wouldn't need the phrases, etc. again [including the file changes])
What you can do to solve this is this:

1) make sure you have the Hack_Tracking_Log.htl file in your htlfiles/ directory;
2) go to Manage Hacks -> Edit Hack Details for the Hack Tracking Log entry;
3) disable all steps for the Install Routine except Run Queries;
4) Save. Now go to Run Install Sequence (it's in the drop-down Controls menu) for the Hack Tracking Log;
5) Choose to run a Real Install, and click Proceed (or Continue?). You will now only encounter the Run Queries step. It will perform that step, which will clear out your hack and hacklog tables entirely!.
6) You will now have an empty HTL installation, which is baaaaad. :) So, we fix! Go to install hack, and choose the Hack Tracking Log that is listed there. Choose Import to Db only ! Hit proceed.
7) The HTL will now be imported to your system, but it will not appear as properly installed, but as Imported-only. To fix that, run this query on your database (manually):

UPDATE hack SET atstep=-1 WHERE hackid=1;

add a table prefix in front of "hack" if you have one.

Then your HTL installation should be fully operational again, and have the column changetype.
If not, your .htl file is corrupted somehow, outdated-beyond-all-outdatedness.


Natch: pretty much, yeah...

CdaKnight
01-28-2004, 02:15 AM
I think I've done something horribly wrong. So I just dropped the hack log tables, redownloaded everything, and reinstalled. Works like a bute.

However, I have two problems with this actual hack now. :\

1) The phrase you specify in your instructions is different that the one inserted into the phrase database.
2) The Javascript menu isn't coming up. I get the little arrow, however the title "Flash", and the titles of all the games come on top of my welcome DIV.

Natch
01-28-2004, 02:41 AM
I think I've done something horribly wrong. So I just dropped the hack log tables, redownloaded everything, and reinstalled. Works like a bute.

However, I have two problems with this actual hack now. :\

1) The phrase you specify in your instructions is different that the one inserted into the phrase database.
2) The Javascript menu isn't coming up. I get the little arrow, however the title "Flash", and the titles of all the games come on top of my welcome DIV.
The phrases don't match up ?

If this is the case, then that would explain why your menu title ain't workin' ;)

What is the phrase title that is being inserted ?

CdaKnight
01-28-2004, 02:45 AM
It was just "flash_title" instead of "flash_addon_title". I was simply alerting you so that it can be remedied. I changed the phrase to match the one inserted by the install in the template, however the menu itself is not being created via the javascript.

Lemme post a screen of what's happening.

Natch
01-28-2004, 02:53 AM
It was just "flash_title" instead of "flash_addon_title". I was simply alerting you so that it can be remedied. I changed the phrase to match the one inserted by the install in the template, however the menu itself is not being created via the javascript.

Lemme post a screen of what's happening.
I think I've gottit now - it looks like you have mislaid some of the HTML for your navbar template:

You are missing the all-important opening <div id=$vbphrase[flash_addon_title]> bit - probably lost when you removed the conditional in one of the navbar inserts.

And the other problem is it seems you have left the conditional in place for one fo the navbar alterations, but removed it in the other - check that out as well.

Check that you have inserted all but the llines containing <if statements - if you want me too look @ your admincp, PM me.

Re: the phrase being mis-inserted, I'll look into that ASAP :) thanks for the heads-up.

CdaKnight
01-28-2004, 03:08 AM
And one more question, and then I'll leave you alone.

For your function that retrieves the flash array, and then displays it, how would I use that on a seperate page? (I'm interesting in having a flash page on my website, which links to flash.php for the forums)

Natch
01-28-2004, 03:32 AM
And one more question, and then I'll leave you alone.

For your function that retrieves the flash array, and then displays it, how would I use that on a seperate page? (I'm interesting in having a flash page on my website, which links to flash.php for the forums)
The functions relating to how it formats the info have been hard-coded to behave as a navbar popup menu - if you want a CSS-styleable UL-LI type menu, I can release that as a separate modification to this hack - gimme a day or so and I'll add an attachment that covers that utility.

For more detail, PM me an IM id - MSN or ICQ and we can chat further about your needs ... :ninja:

Natch
01-28-2004, 06:02 AM
OK - new version of attachment uploaded with different filename so you can get the latest file regardless of your cache offering you older files.

KuraFire
01-28-2004, 10:21 AM
I think I've done something horribly wrong. So I just dropped the hack log tables, redownloaded everything, and reinstalled. Works like a bute.

However, I have two problems with this actual hack now. :\

1) The phrase you specify in your instructions is different that the one inserted into the phrase database.
2) The Javascript menu isn't coming up. I get the little arrow, however the title "Flash", and the titles of all the games come on top of my welcome DIV.
Did the .htl from Natch work from start to finish for you, now?

Natch
01-28-2004, 10:30 AM
Did the .htl from Natch work from start to finish for you, now?
Kura: can you check the HTL file for me ... not installing it actually, but do a test-run with my HTL file and see how it goes ?

I'd love your feedback to see if I did it right :)

KuraFire
01-28-2004, 10:54 AM
Kura: can you check the HTL file for me ... not installing it actually, but do a test-run with my HTL file and see how it goes ?

I'd love your feedback to see if I did it right :)

I'll see if I have time for it later today :)

CdaKnight
01-28-2004, 02:21 PM
I think the only problem that he has concerns his phrase xml file. I just noticed a difference between the one in the template, and the one actually put into the phrase. Easy to fix, I would presume.

Natch
01-28-2004, 02:24 PM
I think the only problem that he has concerns his phrase xml file. I just noticed a difference between the one in the template, and the one actually put into the phrase. Easy to fix, I would presume.
Yeah - it was actually fixed by the stage you were working on it, but the old zipfile was still cached for ya ...

Cheers for being my test-bunny :)

Wolfy.2k
01-28-2004, 02:50 PM
hey natch... is there any chance this can be modified to work wit the v3 arcade? i dont know anything about making hacks but it seems quite similar...?

cheers in advance!

Natch
01-28-2004, 02:59 PM
hey natch... is there any chance this can be modified to work wit the v3 arcade? i dont know anything about making hacks but it seems quite similar...?

cheers in advance!
Yup - should be easy ...

I'll take a look @ it soonest :) and will post in that thread when I have it workin'

Wolfy.2k
01-28-2004, 03:07 PM
cheers bud !!!

/me looks forward to pressing the install button

KuraFire
01-28-2004, 03:46 PM
I think the only problem that he has concerns his phrase xml file. I just noticed a difference between the one in the template, and the one actually put into the phrase. Easy to fix, I would presume.
Ok, good, then I'm no longer scared that my script is broken somewhere. :)

Fi_InCogNiTo
01-29-2004, 05:04 PM
Did you:

a) Edit the path to your forums in the line above this one and
b) make all the other alterations as well ?

The only reason this line will actually do anything is if you also have made the additions to the includes/functions.php file, and added the approriate changes to the navbar template.

Yep, I just tried installing this again and same thing. Maybe it's conflicting with another hack.

Fi_InCogNiTo
01-30-2004, 04:08 PM
Thanks for helping me with my prob Natch. I noticed something though. I'm not sure if it's just on my end or if it's a bug. It will autopopulate when on the forum or anywhere else. But will not autopopulate while on the screen where you are playing the flash game.

Natch
01-30-2004, 04:25 PM
Take a closer look: the popup menu's actually render behind some screen elements: this flash player being one of them...

If it's a problem, try moving the first navbar template mod to teh extreme left or right of the navbar (e.g., make it the first or last TD in the TR ...)

If u need a hand with this, lemme know.

Fi_InCogNiTo
01-30-2004, 04:28 PM
Yea, ur right. Thanks :)

Natch
02-07-2004, 09:33 AM
I have asked the writer of the Arcade if he's OK with my porting this across for his hack, and have not received a Yea or Nay for this - if anyone is interested in this I am happy to talk them thru how to modify this for the Arcade, but I will not be publicly releasing it with the OK from John.

EDIT: OK'ed and released! (https://vborg.vbsupport.ru/showthread.php?t=61278) :)

ImportPassion
02-15-2004, 01:37 PM
how come there is no install button?

Natch
02-15-2004, 08:30 PM
how come there is no install button?
Cos this is an "Addon's" section, I dont warrant an install button ...

ImportPassion
02-15-2004, 09:21 PM
damn, sucks, that is how I keep track of things I want to or did install. oh well, have to try and not forget about it when I need it.

Natch
02-15-2004, 09:23 PM
damn, sucks, that is how I keep track of things I want to or did install. oh well, have to try and not forget about it when I need it.
Subscribe to the thread ?

klaus die maus
03-07-2004, 12:00 PM
HI
i have Problems.
How is that meant with full path qou forum? www.modd.de? in the global or as get errors have rc4
please

klaus die maus
03-07-2004, 04:23 PM
Hello?

Natch
03-09-2004, 07:24 PM
Full path as in the path on the server (eg /home/server/public_html/forums/ or c:\\docs\\forum)

and please wait for more than 4 hours before bumping as not everyone lives on vb.org ...

klaus die maus
03-13-2004, 08:43 AM
Full path as in the path on the server (eg /home/server/public_html/forums/ or c:\\docs\\forum)

and please wait for more than 4 hours before bumping as not everyone lives on vb.org ...

Thank jou

parajsa
11-10-2004, 09:44 PM
Hi there, i try this add-on, but it works only for the default styles, when i tryied to add this one for one other of my style, it does not display the list of games under the menu, it only shows $vbphrase[flash_addon_title], means Flash Games!, and when i click on it it does not show this on this style, but on the default one it works perfectly.

I do know know why, i followed the stepped correctly at both times!

Any help?

Natch
11-11-2004, 12:48 AM
Are you using child styles? if not you will need to make the modifications to all your styles manually in the navbar (or wherever you define your menus)

If this does not help, please link me to your site and I'll take a look for you.

parajsa
11-12-2004, 03:15 PM
I'm not using child styles, and i did the modifications required to the other style, and it was the problem which i emphases as above, but i did them on my local computer and did not put em online.

Natch
11-15-2004, 01:08 AM
Can you take a screenshot for me: I'm not really understanding what you mean...

Rhoads
01-05-2005, 07:50 PM
Nice Hack Natch, but I have een error above my navbar on my homepage :

Warning: Invalid argument supplied for foreach() in /var/www/html/forum/includes/functions.php on line 3806

I see the popup menu, but no games.

Natch
01-07-2005, 01:53 AM
Will happen if you have either messed up the location of the games folder in the function, or you have no games in that folder.

Make sure you have modified the folder location pointing to the location of the games.