PDA

View Full Version : Generic_shell - php include


gbrain
01-16-2006, 09:09 PM
ok.
I have a folder that contains web pages in php, these pages, generate results based on sql statements. These can change depending on what $_POST variables are passed to it.

<table width="800" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td>Dark and Light Auction House &gt;</td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table>
<table width="800" border="1" align="center" cellpadding="2" cellspacing="2">
<tr>
<td><table width="600" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td width="286">&nbsp;</td>
<td width="20">&nbsp;</td>
<td width="274">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="3"><hr /></td>
</tr>
<tr>
<td colspan="3"><div align="center">
<? if ($userdetails["align"] == 0)
{ ?>
<a href="modules.php?name=auction&amp;file=auctionhouse">Enter the &quot;Dark&quot; Auction House </a>
<? } else { ?>
<a href="modules.php?name=auction&amp;file=auctionhouse">Enter the &quot;Light&quot; Auction House </a>
<? } //end if ?>
</div></td>
</tr>
<tr>
<td colspan="3"><hr /></td>
</tr>
<tr>
<td>
<?
$sql_count_items = mysql_query("select * from auction_items");
$count_items = mysql_num_rows($sql_count_items);

?>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td colspan="2"><div align="center">Number of &quot;<strong>Dark&quot;</strong> Items for Sale </div></td>
</tr>
<tr>
<td colspan="2"><hr /></td>
</tr>
<tr>
<td width="67%">Melee Weapons </td>
<? $sql_count = mysql_query("select * from auction_item_weapon where `item_type` = '1' AND `align` = '0'");
$itemcount = mysql_num_rows($sql_count);?>
<td width="33%"><div align="right"><? echo $itemcount; ?>&nbsp;</div></td>
</tr>
<tr>
<td>Ranged Weapons </td>
<? $sql_count = mysql_query("select * from auction_item_weapon where `item_type` = '2' AND `align` = '0'");
$itemcount = mysql_num_rows($sql_count);?>
<td><div align="right"><? echo $itemcount; ?>&nbsp;</div></td>
</tr>
<tr>
<td>Shield</td>
<? $sql_count = mysql_query("select * from auction_item_shield where `item_type` = '1' AND `align` = '0'");
$itemcount = mysql_num_rows($sql_count);?>
<td><div align="right"><? echo $itemcount; ?>&nbsp;</div></td>
</tr>
<tr>
<td>Potions</td>
<? $sql_count = mysql_query("select * from auction_item_potions Where `align` = '0'");
$itemcount = mysql_num_rows($sql_count);?>
<td><div align="right"><? echo $itemcount; ?>&nbsp;</div></td>
</tr>
<?

for ($x = 1;$x <= $count_items;$x++) {
$sql_count = mysql_query("select * from auction_item where `item_type` = '" . $x . "' AND `align` = '0'");
$itemcount = mysql_num_rows($sql_count);

$sql_itemname = mysql_query("select * from auction_items where `id` = '" . $x . "'");
$itemname = mysql_fetch_array($sql_itemname);

?>
<tr>
<td><? echo $itemname["item_name"]; ?></td>
<td><div align="right"><? echo $itemcount; ?>&nbsp;</div></td>
</tr>

<?
} // end for
?>
<tr>
<td colspan="2"><hr /></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
</table> </td>
<td>&nbsp;</td>
<td>
<?
$sql_count_items = mysql_query("select * from auction_items");
$count_items = mysql_num_rows($sql_count_items);

?>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td colspan="2"><div align="center">Number of <strong> &quot;Light</strong>&quot; Items for Sale </div></td>
</tr>
<tr>
<td colspan="2"><hr /></td>
</tr>
<tr>
<td width="67%">Melee Weapons </td>
<? $sql_count = mysql_query("select * from auction_item_weapon where `item_type` = '1' AND `align` = '1'");
$itemcount = mysql_num_rows($sql_count);?>
<td width="33%"><div align="right"><? echo $itemcount; ?>&nbsp;</div></td>
</tr>
<tr>
<td>Ranged Weapons </td>
<? $sql_count = mysql_query("select * from auction_item_weapon where `item_type` = '2' AND `align` = '1'");
$itemcount = mysql_num_rows($sql_count);?>
<td><div align="right"><? echo $itemcount; ?>&nbsp;</div></td>
</tr>
<tr>
<td>Shield</td>
<? $sql_count = mysql_query("select * from auction_item_shield where `item_type` = '1' AND `align` = '1'");
$itemcount = mysql_num_rows($sql_count);?>
<td><div align="right"><? echo $itemcount; ?>&nbsp;</div></td>
</tr>
<tr>
<td>Potions</td>
<? $sql_count = mysql_query("select * from auction_item_potions Where `align` = '1'");
$itemcount = mysql_num_rows($sql_count);?>
<td><div align="right"><? echo $itemcount; ?>&nbsp;</div></td>
</tr>
<?

for ($x = 1;$x <= $count_items;$x++) {
$sql_count = mysql_query("select * from auction_item where `item_type` = '" . $x . "' AND `align` = '1'");
$itemcount = mysql_num_rows($sql_count);

$sql_itemname = mysql_query("select * from auction_items where `id` = '" . $x . "'");
$itemname = mysql_fetch_array($sql_itemname);

?>
<tr>
<td><? echo $itemname["item_name"]; ?></td>
<td><div align="right"><? echo $itemcount; ?>&nbsp;</div></td>
</tr>

<?
} // end for
?>
<tr>
<td colspan="2"><hr /></td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
</table> </td>
</tr>
</table></td>
</tr>
</table>

This simple pages generates a two table list of how many items of each type are in a database.

Can I point vbulletin to this file and show it whithout having to break it up into a VB file and templates.


I have created an index.php file

<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'test'); // change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array(

);

// get special data templates from the datastore
$specialtemplates = array(

);

// pre-cache templates used by all actions
$globaltemplates = array(
'TEST',
);

// pre-cache templates used by specific actions
$actiontemplates = array(

);

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

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

if ($_REQUEST['do'] == 'yes')
{
$HTML = include("../auction/auction_index.php");
}

if ($_REQUEST['do'] == 'no')
{
$HTML = "no";
}



$navbits = array();
$navbits[$parent] = 'Test Page';

$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('GENERIC_SHELL') . '");');

?>




As you can see its uses the Generic_shell, I have added a Do = yes and no. Yes points to the include, But when you run it , the include is put at the top of the page.

http://dndgamer.gbrain.co.uk/auction/index.php?do=yes

Am I missing something, a hook or something.

thanks

G

Update :

I was given this response and was wondering if anyone knew where to find it. ?

<------------------------------------------------------------------------------>


a) I believe Erwin released a hack on vb.org that pulls the content from other php scripts via a php get contents command and displays it on a vb templated page.


thanks