PDA

View Full Version : Putting a php in a template


bc641990
03-25-2008, 09:31 PM
I read tons of tut's and guides on this, but i understand how to get html pages running with vbulletin, but i made this php script, but just don't understand how to get it working with the plugin system.

<?
$weapon1 = $_POST['weapon1'];
$explosive = $_POST['explosive'];
$special = $_POST['special'];
$powerups = $_POST['powerups'];
$health = $_POST['health'];
$speed = $_POST['speed'];
$capturer = $_POST['capturer'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<table align="center">
<tr>
<td><span class="style1">#Equipment Pack<br />
0x004294F4 0x000000<? echo $weapon1 ?><br>
0x004294F8 0x000000<? echo $weapon1 ?><br>
0x004294FC 0x000000<? echo $explosive ?><br>
0x00429500 0x000000<? echo $special ?><br>
0x00429504 0x000000<? echo $powerups ?><br>
0x00429508 0x000000<? echo $health ?><br>
0x0042950C 0x000000<? echo $speed ?><br>
0x00429510 0x000000<? echo $capturer ?><br><br></span></td>
</tr></table>
<table align="center">
<form id="form1" name="form1" method="post" action="">
<tr><td><fieldset><legend>Weapon 1 Replacement:</legend>
<select name="weapon1" id="weapon1">
<option value="01" selected="selected">Blaster Rifle</option>
<option value="02">Arc Caster</option>
<option value="03">Carbonite Freeze Gun</option>
<option value="04">Incinerator</option>
<option value="05">Shotgun</option>
<option value="06">Sniper Rifle</option>
<option value="07">Chaingun</option>
<option value="08">Bowcaster</option>
<option value="09">Rocket Launcher</option>
<option value="0A">Blaster Pistol</option>
<option value="0B">Fusion Cutter</option>
<option value="0C">Tri Shot</option>
<option value="0D">EMP Launcher</option>
<option value="0E">Explosive Blaster Pistol</option>
<option value="0F">Grenade Launcher</option>
<option value="10">Guided Rocket</option>
<option value="11">Orbital Strike</option>
<option value="13">Thermal Detonator</option>
<option value="14">Detpacks</option>
<option value="15">Proximity Mines</option>
<option value="16">Cluster Grenade</option>
<option value="17">Wrist Rocket</option>
<option value="19">Health and Ammo</option>
<option value="1A">Auto-Turret</option>
<option value="1B">Recond Droid</option>
<option value="1C">Stealth Suit</option>
<option value="1D">Jet Pack</option>
<option value="1E">Jump Pack</option>
<option value="1F">Personal Shield</option>
<option value="21">Rally</option>
<option value="22">Rage</option>
<option value="23">Stamina</option>
<option value="24">Regenerate</option>
</select></fieldset>
<fieldset><legend>Weapon 2 Replacement:<br /></legend>
<select name="weapon2" id="weapon2">
<option value="00">Blaster Pistol</option>
<option value="01">Fusion Cutter</option>
<option value="02">Tri Shot</option>
<option value="03">EMP Launcher</option>
<option value="04">Explosive Blaster Pistol</option>
<option value="05">Grenade Launcher</option>
<option value="06">Guided Rocket</option>
<option value="07">Orbital Strike</option>
<option value="09">Thermal Detonator</option>
<option value="0A">Detpacks</option>
<option value="0B">Proximity Mines</option>
<option value="0C">Cluster Grenade</option>
<option value="0D">Wrist Rocket</option>
<option value="0F">Health and Ammo</option>
<option value="10">Auto Turret</option>
<option value="11">Recond Droid</option>
<option value="12">Stealth Suit</option>
<option value="13">Jetpack</option>
<option value="14">Jump Pack</option>
<option value="15">Personal Shield</option>
<option value="17">Rally</option>
<option value="18">Rage</option>
<option value="19">Stamina</option>
<option value="1A">Regenerate</option>
</select></fieldset>

<fieldset><legend>Explosive:<br /></legend>
<select name="explosive" id="explosive">
<option value="01">Thermal Detonator</option>
<option value="02">Detpacks</option>
<option value="03">Proximity Mines</option>
<option value="04">Cluster Grenade</option>
<option value="05">Wrist Rocket</option>
<option value="07">Health and Ammo</option>
<option value="08">Auto Turret</option>
<option value="09">Recond Droid</option>
<option value="0A">Stealth Suit</option>
<option value="0B">Jetpack</option>
<option value="0C">Jump Pack</option>
<option value="0D">Personal Shield</option>
<option value="0F">Rally</option>
<option value="10">Rage</option>
<option value="11">Stamina</option>
<option value="12">Regenerate</option>
</select></fieldset>

<fieldset><legend>Special Items:<br /></legend>
<select name="special" id="special">
<option value="01">Health and Ammo</option>
<option value="02">Auto Turret</option>
<option value="03">Recond Droid</option>
<option value="04">Stealth Suit</option>
<option value="05">Jetpack</option>
<option value="06">Jump Pack</option>
<option value="07">Personal Shield</option>
<option value="09">Rally</option>
<option value="0A">Rage</option>
<option value="0B">Stamina</option>
<option value="0C">Regenerate</option>
</select></fieldset>
</td><td>
<fieldset><legend>Power Ups:<br /></legend>
<select name="powerups" id="powerups">
<option value="01">Rally</option>
<option value="02">Rage</option>
<option value="03">Stamina</option>
<option value="04">Regenerate</option>
</select></fieldset>
<fieldset><legend>Health:<br /></legend>
<select name="health" id="health">
<option value="04" selected="selected">No Change</option>
<option value="01">Level 1</option>
<option value="02">Level 2</option>
<option value="03">Level 3</option>
</select></fieldset>
<fieldset><legend>Speed:<br /></legend>
<select name="speed" id="speed">
<option value="04">No Change</option>
<option value="01">Level 1</option>
<option value="02">Level 2</option>
<option value="03">Level 3</option>
</select></fieldset>
<fieldset><legend>Capture Rate:<br /></legend>
<select name="capturer" id="capturer">
<option value="04">No Change</option>
<option value="01">Level 1</option>
<option value="02">Level 2</option>
<option value="03">Level 3</option>
</select></fieldset></td></tr>
<tr><td colspan="2">
<center><input type="submit" name="Submit" value="Submit" /></center>
</form></td></tr>
</table>
</body>
</html>


Thanks guys,
Brandon

Amenadiel
03-26-2008, 12:24 AM
why use a plugin?

just build a custom page, you just need to add header and footer templates (well, and navbar if you like).

try something like this:


<?php
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NOSHUTDOWNFUNC', 1);
define('THIS_SCRIPT', 'your_script_name');

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups


// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################

$vbulletin->input->clean_array_gpc('r', array(
'weapon1' => TYPE_STR,
'explosive' => TYPE_STR,
'special' => TYPE_STR,
'powerups' => TYPE_UINT,
'health' => TYPE_UINT,
'speed' => TYPE_UINT,
'capturer' => TYPE_STR,
));


$weapon1 = $vbulletin->GPC['weapon1'];
$explosive = $vbulletin->GPC['explosive'];
$special = $vbulletin->GPC['special'];
$powerups = $vbulletin->GPC['powerups'];
$health = $vbulletin->GPC['health'];
$speed = $vbulletin->GPC['speed'];
$capturer = $vbulletin->GPC['capturer'];


$navbits = array();
$navbits[$parent] = 'Your forum root title';
$navbits = construct_navbits($navbits);

eval('$navbar = "' . fetch_template('navbar') . '";');
$navbar = process_replacement_vars($navbar);

eval('$headinclude = "' . fetch_template('headinclude') . '";');
$headinclude = process_replacement_vars($headinclude);

eval('$footer = "' . fetch_template('footer') . '";');
$footer = process_replacement_vars($footer);





echo<<<VAPRINT
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
$headinclude

<title>Your page title</title>
</head>

$header
$navbar



VAPRINT;

//








$output .= <<<VAPRINT
<table align="center">
<tr>
<td><span class="style1">#Equipment Pack<br />
$archivo <br>
$weapon1 <br>
$weapon1 <br>
$explosive <br>
$special <br>
$powerups <br>
$health <br>
$speed <br>
$capturer <br><br></span></td>
</tr></table>
<table align="center">
<form id="form1" name="form1" method="post" action="">
<tr><td><fieldset><legend>Weapon 1 Replacement:</legend>
<select name="weapon1" id="weapon1">
<option value="01" selected="selected">Blaster Rifle</option>
<option value="02">Arc Caster</option>
<option value="03">Carbonite Freeze Gun</option>
<option value="04">Incinerator</option>
<option value="05">Shotgun</option>
<option value="06">Sniper Rifle</option>
<option value="07">Chaingun</option>
<option value="08">Bowcaster</option>
<option value="09">Rocket Launcher</option>
<option value="0A">Blaster Pistol</option>
<option value="0B">Fusion Cutter</option>
<option value="0C">Tri Shot</option>
<option value="0D">EMP Launcher</option>
<option value="0E">Explosive Blaster Pistol</option>
<option value="0F">Grenade Launcher</option>
<option value="10">Guided Rocket</option>
<option value="11">Orbital Strike</option>
<option value="13">Thermal Detonator</option>
<option value="14">Detpacks</option>
<option value="15">Proximity Mines</option>
<option value="16">Cluster Grenade</option>
<option value="17">Wrist Rocket</option>
<option value="19">Health and Ammo</option>
<option value="1A">Auto-Turret</option>
<option value="1B">Recond Droid</option>
<option value="1C">Stealth Suit</option>
<option value="1D">Jet Pack</option>
<option value="1E">Jump Pack</option>
<option value="1F">Personal Shield</option>
<option value="21">Rally</option>
<option value="22">Rage</option>
<option value="23">Stamina</option>
<option value="24">Regenerate</option>
</select></fieldset>
<fieldset><legend>Weapon 2 Replacement:<br /></legend>
<select name="weapon2" id="weapon2">
<option value="00">Blaster Pistol</option>
<option value="01">Fusion Cutter</option>
<option value="02">Tri Shot</option>
<option value="03">EMP Launcher</option>
<option value="04">Explosive Blaster Pistol</option>
<option value="05">Grenade Launcher</option>
<option value="06">Guided Rocket</option>
<option value="07">Orbital Strike</option>
<option value="09">Thermal Detonator</option>
<option value="0A">Detpacks</option>
<option value="0B">Proximity Mines</option>
<option value="0C">Cluster Grenade</option>
<option value="0D">Wrist Rocket</option>
<option value="0F">Health and Ammo</option>
<option value="10">Auto Turret</option>
<option value="11">Recond Droid</option>
<option value="12">Stealth Suit</option>
<option value="13">Jetpack</option>
<option value="14">Jump Pack</option>
<option value="15">Personal Shield</option>
<option value="17">Rally</option>
<option value="18">Rage</option>
<option value="19">Stamina</option>
<option value="1A">Regenerate</option>
</select></fieldset>

<fieldset><legend>Explosive:<br /></legend>
<select name="explosive" id="explosive">
<option value="01">Thermal Detonator</option>
<option value="02">Detpacks</option>
<option value="03">Proximity Mines</option>
<option value="04">Cluster Grenade</option>
<option value="05">Wrist Rocket</option>
<option value="07">Health and Ammo</option>
<option value="08">Auto Turret</option>
<option value="09">Recond Droid</option>
<option value="0A">Stealth Suit</option>
<option value="0B">Jetpack</option>
<option value="0C">Jump Pack</option>
<option value="0D">Personal Shield</option>
<option value="0F">Rally</option>
<option value="10">Rage</option>
<option value="11">Stamina</option>
<option value="12">Regenerate</option>
</select></fieldset>

<fieldset><legend>Special Items:<br /></legend>
<select name="special" id="special">
<option value="01">Health and Ammo</option>
<option value="02">Auto Turret</option>
<option value="03">Recond Droid</option>
<option value="04">Stealth Suit</option>
<option value="05">Jetpack</option>
<option value="06">Jump Pack</option>
<option value="07">Personal Shield</option>
<option value="09">Rally</option>
<option value="0A">Rage</option>
<option value="0B">Stamina</option>
<option value="0C">Regenerate</option>
</select></fieldset>
</td><td>
<fieldset><legend>Power Ups:<br /></legend>
<select name="powerups" id="powerups">
<option value="01">Rally</option>
<option value="02">Rage</option>
<option value="03">Stamina</option>
<option value="04">Regenerate</option>
</select></fieldset>
<fieldset><legend>Health:<br /></legend>
<select name="health" id="health">
<option value="04" selected="selected">No Change</option>
<option value="01">Level 1</option>
<option value="02">Level 2</option>
<option value="03">Level 3</option>
</select></fieldset>
<fieldset><legend>Speed:<br /></legend>
<select name="speed" id="speed">
<option value="04">No Change</option>
<option value="01">Level 1</option>
<option value="02">Level 2</option>
<option value="03">Level 3</option>
</select></fieldset>
<fieldset><legend>Capture Rate:<br /></legend>
<select name="capturer" id="capturer">
<option value="04">No Change</option>
<option value="01">Level 1</option>
<option value="02">Level 2</option>
<option value="03">Level 3</option>
</select></fieldset></td></tr>
<tr><td colspan="2">
<center><input type="submit" name="Submit" value="Submit" /></center>
</form></td></tr>
</table>

$footer

VAPRINT;

echo $output;


?>

Opserty
03-26-2008, 09:59 AM
Have you checked the manual too? Including External Files (http://www.vbulletin.com/docs/html/main/templates_externalfiles)

bc641990
03-26-2008, 03:51 PM
thanks alot man, but is there any place to read on how to do something like that

Have you checked the manual too? Including External Files (http://www.vbulletin.com/docs/html/main/templates_externalfiles)

yea but wont i have to make a lot of files to do that

Thanks guys,
Brandon

RobDog888
03-26-2008, 04:43 PM
<font color="darkgreen">That is the nature of programming. If you want to do something complex then the amount of code goes up. You shouldnt be using that much code in a plugin anyways as its bad for overhead.</font>

bc641990
03-27-2008, 01:57 PM
the include works great thanks everyone for your help :-)

bc641990
10-07-2008, 01:42 AM
why use a plugin?

just build a custom page, you just need to add header and footer templates (well, and navbar if you like).

try something like this:


<?php
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NOSHUTDOWNFUNC', 1);
define('THIS_SCRIPT', 'your_script_name');

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups


// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################

$vbulletin->input->clean_array_gpc('r', array(
'weapon1' => TYPE_STR,
'explosive' => TYPE_STR,
'special' => TYPE_STR,
'powerups' => TYPE_UINT,
'health' => TYPE_UINT,
'speed' => TYPE_UINT,
'capturer' => TYPE_STR,
));


$weapon1 = $vbulletin->GPC['weapon1'];
$explosive = $vbulletin->GPC['explosive'];
$special = $vbulletin->GPC['special'];
$powerups = $vbulletin->GPC['powerups'];
$health = $vbulletin->GPC['health'];
$speed = $vbulletin->GPC['speed'];
$capturer = $vbulletin->GPC['capturer'];


$navbits = array();
$navbits[$parent] = 'Your forum root title';
$navbits = construct_navbits($navbits);

eval('$navbar = "' . fetch_template('navbar') . '";');
$navbar = process_replacement_vars($navbar);

eval('$headinclude = "' . fetch_template('headinclude') . '";');
$headinclude = process_replacement_vars($headinclude);

eval('$footer = "' . fetch_template('footer') . '";');
$footer = process_replacement_vars($footer);





echo<<<VAPRINT
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
$headinclude

<title>Your page title</title>
</head>

$header
$navbar



VAPRINT;

//








$output .= <<<VAPRINT
<table align="center">
<tr>
<td><span class="style1">#Equipment Pack<br />
$archivo <br>
$weapon1 <br>
$weapon1 <br>
$explosive <br>
$special <br>
$powerups <br>
$health <br>
$speed <br>
$capturer <br><br></span></td>
</tr></table>
<table align="center">
<form id="form1" name="form1" method="post" action="">
<tr><td><fieldset><legend>Weapon 1 Replacement:</legend>
<select name="weapon1" id="weapon1">
<option value="01" selected="selected">Blaster Rifle</option>
<option value="02">Arc Caster</option>
<option value="03">Carbonite Freeze Gun</option>
<option value="04">Incinerator</option>
<option value="05">Shotgun</option>
<option value="06">Sniper Rifle</option>
<option value="07">Chaingun</option>
<option value="08">Bowcaster</option>
<option value="09">Rocket Launcher</option>
<option value="0A">Blaster Pistol</option>
<option value="0B">Fusion Cutter</option>
<option value="0C">Tri Shot</option>
<option value="0D">EMP Launcher</option>
<option value="0E">Explosive Blaster Pistol</option>
<option value="0F">Grenade Launcher</option>
<option value="10">Guided Rocket</option>
<option value="11">Orbital Strike</option>
<option value="13">Thermal Detonator</option>
<option value="14">Detpacks</option>
<option value="15">Proximity Mines</option>
<option value="16">Cluster Grenade</option>
<option value="17">Wrist Rocket</option>
<option value="19">Health and Ammo</option>
<option value="1A">Auto-Turret</option>
<option value="1B">Recond Droid</option>
<option value="1C">Stealth Suit</option>
<option value="1D">Jet Pack</option>
<option value="1E">Jump Pack</option>
<option value="1F">Personal Shield</option>
<option value="21">Rally</option>
<option value="22">Rage</option>
<option value="23">Stamina</option>
<option value="24">Regenerate</option>
</select></fieldset>
<fieldset><legend>Weapon 2 Replacement:<br /></legend>
<select name="weapon2" id="weapon2">
<option value="00">Blaster Pistol</option>
<option value="01">Fusion Cutter</option>
<option value="02">Tri Shot</option>
<option value="03">EMP Launcher</option>
<option value="04">Explosive Blaster Pistol</option>
<option value="05">Grenade Launcher</option>
<option value="06">Guided Rocket</option>
<option value="07">Orbital Strike</option>
<option value="09">Thermal Detonator</option>
<option value="0A">Detpacks</option>
<option value="0B">Proximity Mines</option>
<option value="0C">Cluster Grenade</option>
<option value="0D">Wrist Rocket</option>
<option value="0F">Health and Ammo</option>
<option value="10">Auto Turret</option>
<option value="11">Recond Droid</option>
<option value="12">Stealth Suit</option>
<option value="13">Jetpack</option>
<option value="14">Jump Pack</option>
<option value="15">Personal Shield</option>
<option value="17">Rally</option>
<option value="18">Rage</option>
<option value="19">Stamina</option>
<option value="1A">Regenerate</option>
</select></fieldset>

<fieldset><legend>Explosive:<br /></legend>
<select name="explosive" id="explosive">
<option value="01">Thermal Detonator</option>
<option value="02">Detpacks</option>
<option value="03">Proximity Mines</option>
<option value="04">Cluster Grenade</option>
<option value="05">Wrist Rocket</option>
<option value="07">Health and Ammo</option>
<option value="08">Auto Turret</option>
<option value="09">Recond Droid</option>
<option value="0A">Stealth Suit</option>
<option value="0B">Jetpack</option>
<option value="0C">Jump Pack</option>
<option value="0D">Personal Shield</option>
<option value="0F">Rally</option>
<option value="10">Rage</option>
<option value="11">Stamina</option>
<option value="12">Regenerate</option>
</select></fieldset>

<fieldset><legend>Special Items:<br /></legend>
<select name="special" id="special">
<option value="01">Health and Ammo</option>
<option value="02">Auto Turret</option>
<option value="03">Recond Droid</option>
<option value="04">Stealth Suit</option>
<option value="05">Jetpack</option>
<option value="06">Jump Pack</option>
<option value="07">Personal Shield</option>
<option value="09">Rally</option>
<option value="0A">Rage</option>
<option value="0B">Stamina</option>
<option value="0C">Regenerate</option>
</select></fieldset>
</td><td>
<fieldset><legend>Power Ups:<br /></legend>
<select name="powerups" id="powerups">
<option value="01">Rally</option>
<option value="02">Rage</option>
<option value="03">Stamina</option>
<option value="04">Regenerate</option>
</select></fieldset>
<fieldset><legend>Health:<br /></legend>
<select name="health" id="health">
<option value="04" selected="selected">No Change</option>
<option value="01">Level 1</option>
<option value="02">Level 2</option>
<option value="03">Level 3</option>
</select></fieldset>
<fieldset><legend>Speed:<br /></legend>
<select name="speed" id="speed">
<option value="04">No Change</option>
<option value="01">Level 1</option>
<option value="02">Level 2</option>
<option value="03">Level 3</option>
</select></fieldset>
<fieldset><legend>Capture Rate:<br /></legend>
<select name="capturer" id="capturer">
<option value="04">No Change</option>
<option value="01">Level 1</option>
<option value="02">Level 2</option>
<option value="03">Level 3</option>
</select></fieldset></td></tr>
<tr><td colspan="2">
<center><input type="submit" name="Submit" value="Submit" /></center>
</form></td></tr>
</table>

$footer

VAPRINT;

echo $output;


?>


thanks man I figured out how to get pages like this to work but for some reason I cant get the $navbar to display and reasons?