The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Help needed to integrate some php with vbulletin
Hi all i have created a vbulletin page using this mod https://vborg.vbsupport.ru/showthread.php?t=62164, what i want to do is incorporate a whoisip lookup script within it (it's the first step of two) here's the entire php for whois:
PHP Code:
HTML Code:
$stylevar[htmldoctype] <html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]"> <head> <title>$vboptions[bbtitle]</title> $headinclude </head> <body> $header $navbar <table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center"> <tr> <td class="tcat">IP Lookup</td> </tr> <tr> <td><div><form action[B]="<?=$_SERVER['PHP_SELF'];?>">[/B] <p><b><label for="domain">Domain/IP Address:</label></b> <input type="text" name="domain" id="domain" value="<?=$domain;?>"> <input type="submit" value="Lookup"></p> </form> <? if($domain) { $domain = trim($domain); if(ValidateIP($domain)) { $result = LookupIP($domain); } elseif(ValidateDomain($domain)) { $result = LookupDomain($domain); } else die("Invalid Input!"); echo "<pre>\r\n" . $result . "\r\n</pre>\r\n"; } ?> </div></td> </tr> </table> $footer </body> </html> HTML Code:
<tr><td class="vbmenu_option"><span onmouseover="this.style.cursor='hand';" onClick="window.open('modcp/whois.php','edit','width=900,height=380,scrollbars=yes')">WhoisIP for $post[username]: $post[ip]</span></td></tr> Any help at all would be great! |
#2
|
|||
|
|||
Well, for the form part I think you just need to get rid of the <? and ?>, like
Code:
<td><div><form action="$_SERVER['PHP_SELF']"> <p><b><label for="domain">Domain/IP Address:</label></b> <input type="text" name="domain" id="domain" value="$domain"> <input type="submit" value="Lookup"></p> </form> Also, the PHP you have there won't work in a template, [S]you'll need to put it in a plugin, which means you'll have to find a hook where it can be executed.[/S] Edit: Sorry, I reread your post - you won't necessarily need a plugin if you've got your own php file. Both of these come from the fact that a vbulletin template is kind of like a php stand alone program but not quite, you don't need <? and ?> and you're limited to a certain set of functions you can call in conditionals. |
#3
|
||||
|
||||
Thanks for the reply but i get the same error:
Quote:
|
#4
|
|||
|
|||
oh, right, i keep forgetting, I think you need to remove the single quotes, try
Code:
$_SERVER[PHP_SELF] Code:
{$_SERVER['PHP_SELF']} |
#5
|
||||
|
||||
great! removing the ' worked, now i need to know how to add all this or call it?
PHP Code:
|
#6
|
|||
|
|||
Hmm...sorry, I guess I'm not sure if you're using a separate php file or not. I guess not or else you'd just put it in there. So the alternative is a plugin. You could just use the global_start hook since your code only defines things and doesn't do stuff on it's own. You'd normally want to find a place that only includes the code when you need it of course.
And hopefully there won't be any variable scope problems. |
#7
|
||||
|
||||
I can use a seperate php file no problem, i just don't know how to link the two parts, in my first post it is all together and runs as a stand alone web page, but i removed the stuff in the HTML tags and plonked it in to my newly created template, how do i now link that with the rest of it.....i'm no coder so i'll need a kind of walk through if thats ok?
--------------- Added [DATE]1266687519[/DATE] at [TIME]1266687519[/TIME] --------------- All the left over code i put in a plugin, used global_start as the hook, my template now looks like this HTML Code:
$stylevar[htmldoctype] $iplookup <html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]"> <head> <title>$vboptions[bbtitle]</title> $headinclude </head> <body> $header $navbar <table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center"> <tr> <td class="tcat">IP Lookup</td> </tr> <tr> <td><div><form action="$_SERVER[PHP_SELF]"> <p><b><label for="domain">Domain/IP Address:</label></b> <input type="text" name="domain" id="domain" value="$domain"> <input type="submit" value="Lookup"></p> </form><? if($domain) { $domain = trim($domain); if(ValidateIP($domain)) { $result = LookupIP($domain); } elseif(ValidateDomain($domain)) { $result = LookupDomain($domain); } else die("Invalid Input!"); echo "<pre>\r\n" . $result . "\r\n</pre>\r\n"; } ?> </div></td></tr> </table> $footer </body> </html> |
#8
|
|||
|
|||
Sorry again (I end up saying that a lot). As is the case all too often when I try to help someone, by the time I got through looking at the code I had forgotten about the very first line of your first post where you posted a link explaining what you're doing. If you've created a separate php file like in those instructions, then you just need to put your "leftover" code in that file somewhere instead of a plugin. At the top should be fine.
The output of your page should come from the Code:
eval('print_output("' . fetch_template('TEST') . '");'); |
#9
|
||||
|
||||
Where you say "at the top" do you mean above
PHP Code:
--------------- Added [DATE]1266688703[/DATE] at [TIME]1266688703[/TIME] --------------- I added the rest of that code below <? here's my page http://www.thecodecage.com/forumz/iptest.php i don't get an output to the page when searching an ip? |
#10
|
|||
|
|||
OK, I guess if I were doing it I'd probably put it just under the comment that says "Start main script".
Looking where you posted above, you need to get rid of some of the stuff out of that template, specifically: Code:
<? if($domain) { $domain = trim($domain); if(ValidateIP($domain)) { $result = LookupIP($domain); } elseif(ValidateDomain($domain)) { $result = LookupDomain($domain); } else die("Invalid Input!"); echo "<pre>\r\n" . $result . "\r\n</pre>\r\n"; } ?> Code:
<if condition="$domain"> <pre> $result </pre> </if> Code:
$domain = trim($domain); if(ValidateIP($domain)) { $result = LookupIP($domain); } elseif(ValidateDomain($domain)) { $result = LookupDomain($domain); } else $result = "Invalid Input!"; To answer your other question, I haven't figured out all the code so I don't know how it's supposed to do it's thing when you submit the form. Because the action is "PHP_SELF" I figure it must load the same page again. ETA: I added an <if> tag to the template changes above, and that answers the question, I think - that part only appears if $domain is defined, so it's just the same page loaded again when submit is pressed. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|