PDA

View Full Version : Need some help finishing a hack.


JJR512
09-07-2001, 06:50 AM
What I'm working on is changing the Forum Rules, in some places, from the actual list of rules, to a link that will pop up a window with the rules there. Sort of like the Get More link in the smilies box.

The specific problem I'm having is getting the forumid through the system, so it will be able to figure out just what exactly the rules are.

Here's what I have so far.

The link I am using to open the popup is this:
<a href="javascript:showforumrules(420,512,'$session[sessionhash]')">Forum Rules</a>

That operates a custom function that I've put in the vbcode.js file:
function showforumrules(x,y,sessionhash) {
window.open("misc.php?action=showforumrules&forumid=$forum[forumid]&s="+sessionhash, "smilies", "toolbar=no,scrollbars=yes,resizable=yes,width="+x+",height="+y);
}

Which in turns works with some custom code I've put in the misc.php file:
if ($action=="showforumrules") {
$templatesused = ""; // Only one template used so load it when called
include("./global.php");
$forumid=verifyid("forum",$forumid);
$foruminfo=getforuminfo($forumid);
$bbcodeon=iif($foruminfo[allowbbcode],$ontext,$offtext);
$imgcodeon=iif($foruminfo[allowimages],$ontext,$offtext);
$htmlcodeon=iif($foruminfo[allowhtml],$ontext,$offtext);
$smilieson=iif($foruminfo[allowsmilies],$ontext,$offtext);
eval("dooutput(\"".gettemplate("showforumrules")."\");");
}
This uses a custom template I created, showforumrules: (I've removed most of the formatting for simplicity)
<b>Forum Rules</b><br>
You <b>may $rules[postnew]</b> post new threads.<br>
You <b>may $rules[postreply]</b> post replies.<br>
You <b>may $rules[attachment]</b> post attachments.<br>
You <b>may $rules[edit]</b> edit your posts.<br>
<br>
<b>Posting Rules</b><br>
HTML code is <b>$htmlcodeon</b>.<br>
<a href="misc.php?s=$session[sessionhash]&action=showsmilies">Smilies</a> are <b>$smilieson</b>.<br>
<a href="misc.php?s=$session[sessionhash]&action=bbcode">vB code</a> is <b>$bbcodeon</b>.<br>
[IMG] code is <b>$imgcodeon</b>.

I also had to add the following to the forumdisplay template, or else the link would not work:
<script language="Javascript" src="vbcode.js"></script>

The specific problem I am having is with the bit that I've put in the vbcode.js file. I've tried to use &forumid=$forum[forumid] to pass the forumid along to the code I put in misc.php, but it's not working. Now if I take out &forumid=$forum[forumid] and just hardcode a forumid number, like &forumid=1, then it works fine, but that's not the best way. It should be able to get the forumid through the variable, but it isn't working.

Can someone please help me with this?

Scott MacVicar
09-07-2001, 07:28 AM
I'm pretty sure the forum array is not passed in to the vbcode.js file

just pass in the forum id the way you pass in the width, height and session hash. That should work.

JJR512
09-07-2001, 07:36 AM
Ahh... could you please be a bit more specific on how to do that? You see, I don't actually know what I'm doing!

JJR512
09-07-2001, 07:41 AM
I tried making the link like this:
<a href="javascript:showforumrules(420,512,'$session[sessionhash]','$forum[forumid]')">Forum Rules</a>
But I have two problems with that. The actual URL that the link becomes is now like javascript:showforumrules(420,512,'',''), rather than javascript:showforumrules(420,512,'') as it used to be. In other words, the forumid number is not showing up in the link. So that's the first thing to solve. The next thing I'm wondering about is will the code in the vbcode.js file know what to do with that extra info, or do I need to add to that part, too, and if so, how?

(Note: Of course the real links do not have the space in between java and script.)

Scott MacVicar
09-07-2001, 07:54 AM
<a href="javascript:showforumrules(420,512,'$session[sessionhash]','$foruminfo[forumid]')">Forum Rules</a>

function showforumrules(x,y,sessionhash,forumid) {
window.open("misc.php?action=showforumrules&forumid="+forumid+"&s="+sessionhash, "smilies", "toolbar=no,scrollbars=yes,resizable=yes,width="+x+",height="+y);
}

I ain't no javascript expert but that should hopefully work

JJR512
09-07-2001, 08:11 AM
Well, the forumid number now shows up in the link, but when I click on it, it just says "Error on page" (at the bottom of IE).

Scott MacVicar
09-07-2001, 08:30 AM
I'm right, i ain't not javascript expert =D

function showforumrules(x,y,sessionhash,forumid) {
window.open("misc.php?action=showforumrules&forumid="+forumid+"&s="+sessionhash, "smilies", "toolbar=no,scrollbars=yes,resizable=yes,width="+x+",height="+y);
}

there is a problem in there, hopefully someone can helpyou with the function.

JJR512
09-07-2001, 06:15 PM
Can someone please help?

ToraTora!
09-07-2001, 06:24 PM
did you add the java in the styles area, such as in the header area>? Most of the java has to go in that area, or you get a error everytime. Just rite above the <meta blah blah blah>
info.

ToraTora!
09-07-2001, 06:33 PM
basically, this part would go into your styles area...above the meta tag stuff...

<!-- Pop Up-->
<script language=javascript>
<!--
function showforumrules(newin) {
flyout=window.open(newin,"flyout","resizeable=no,scrollbars=no,toolbar=no,width= 400,height=360,top=50,left=190")
}
// -->

</script>

than, the next part would be something like this, added where you would want a form button basically.....(can use image to...not just a button, so it could go in your main menu of your forums)

<form>
<input type="button" name="Submit" value="Rules" onclick="showforumrules('misc.php?s=$session[sessionhash]&action=showforumrules&forumid=$forumid')">
</form>

Im thinking your missing something though, because getinfo uses a $userinfo[userid] at the end of the script, and $forumid by itself doesnt look rite....

JJR512
09-07-2001, 06:34 PM
Now see I'm not really sure what you mean by that. Earlier when I said I don't know what I'm doing, I wasn't kidding!

But I thought that by putting the script in the vbcode.js, and that the file is called in the header section, was all that I needed? Do I need something else?

ToraTora!
09-07-2001, 06:41 PM
The code that i added just above your reply, is what i used for the mood hack, just with your variables. Try using it once..it may work.... It pops open my script to display the usermood, which is a seperate script in the member.php file.

The thing that i think may hold this off, is the fact you use a $action call, which is a defined call in member.php, and showthread.php...etc...
the link itself has to be somewhere defined, as a actual action call such as this

if ($action == 'showforumrules') {
$templatesused = "showforumrules";
include("./global.php");

you know..that type of deal...

JJR512
09-07-2001, 06:42 PM
OK, forget my last post, I guess I was writing it at the same time you were posting your second reply. :)

But I thought that by putting the code in the vbcode.js file, that I wouldn't have to put it in the header. That's how the smilies popup window works. I basically copied the whole smilies popup and just changed which template it used (and of course the function names).

The whole thing works. A window pops up. The problem is that I can't get the forumid number to get into the template that's being used. I can't get it from the link into the template. If I hardcode the forumid number, it works fine, but if I use the variable, it doesn't work. I get an error message that no forumid was specified. There must be something wrong with the syntax of the code that PPN gave in his last message; it's not properly getting the forumid number from the link.

JJR512
09-07-2001, 06:44 PM
Originally posted by ToraTora!
...The thing that i think may hold this off, is the fact you use a $action call, which is a defined call in member.php, and showthread.php...etc...
the link itself has to be somewhere defined, as a actual action call such as this

if ($action == 'showforumrules') {
$templatesused = "showforumrules";
include("./global.php");



you know..that type of deal...

Yeah, I put something like that in misc.php. It's detailed in the original message above.

ToraTora!
09-07-2001, 06:53 PM
yeh i just noticed that...sorry bout that...

i think there has to be something with the forum id bit.

I do not think a person can get away, with just having $forumid at the end like that...

everything, even replying to this thread, has some sort of variable tied in with it...

newreply.php?s=&action=newreply&threadid=

thats the trick...trying to get the forumid number in there...

Think along the lines of getinfo, when you click on a username..how does it find the correct user?

=&action=getinfo&userid=$userinfo[userid]

so, something like this may work..dont know...

=&action=showforumrules&forumid=$foruminfo[forumid]

There has to be something like foruminfo, in order to kick in the id, just like getinfo uses..

Try that foruminfo code once..

ToraTora!
09-07-2001, 06:57 PM
maybe instead of $foruminfo...

try....$forumdisplay

JJR512
09-07-2001, 07:07 PM
The forumid is determined in the link, like this:
<a href="java script:showforumrules(420,512,'$session[sessionhash]','$foruminfo[forumid]')">Forum Rules</a>
But the javascript is not recognizing it. I guess what PPN was trying to do was pass the forumid through the link into the javascript, like the way the sessionhash variable is. But the problem is that the javascript is not properly interpreting the variable. I think it's gotta be a syntax problem with the javascript.

But in the meantime, I'll try the other stuff you mentioned.

ToraTora!
09-08-2001, 01:36 PM
the biggest thing, is that when the $action variable is called, it needs to know where its going...

Getinfo uses the $userinfo[username]

so, your script, or mine, would work, if you could pinpoint where it is, your script has to goto.

the $forumid alone will not work i dont think, because there is nothing telling the script, where exactly it is supposed to go.
That is why, when you hardcoded it into your addy, it worked, because it knew now where to go.
The same holds true for getinfo. If you took the username part out from the little tidbit i showed you above, it would not display anything either, because it needs that username, to distinquish the username variables, and id's of all your members.

That is the same for forumid...forumid needs to be whatever you numbered or set the faqs at...(when you add a new forum, there is a id that you can add, to find where it is supposed to be directed to)

If the faq is in lets say...in a thread...than it would have to be something like..


http://www.vbulletin.com/forum/newreply.php?s=&action=newreply&threadid=27552

By posting the address, for this thread, you can see that 27552 is the threadid...however, what distinquishes that id?

newreply&threadid=forumid[$threadid]

the threadid variable, is what automatically assigns the basic directions, or map of your site.
You need to have something resembling that in your script...

Getinfo is like this...

http://www.vbulletin.com/forum/member.php?s=&action=getinfo&userid=userinfo[$username]

im am almost postive..that you have to have something else go along with the forumid bit....because the script has no idea, of where it is going to, or what id number, or set addy your faqs are set to.....nothing is assigned to it...just forumid...which could be anything in your fourms, because forum id, is of course, your added forums id number.

ok...im not 100% on all of this, but i am pretty sure that i am on the rite track...lol..