1
C6Vagabond
Php blocks (VWAR)
  • 2004/10/4 21:31

  • C6Vagabond

  • Just popping in

  • Posts: 3

  • Since: 2004/10/4


Hi guys. Im trying to make a block in my XOOPS website so it can show this php script:

http://vwar.charlieatsix.com/extra/nextactions.php

When i try to copy the php code into a block it wont show on the main page. I get an empty block.

This is the code of the block:

<?php
global $vwardb;
ob_start();
include("http://vwar.charlieatsix.com/extra/nextactions.php");
$output = ob_get_contents();
ob_end_clean();
$content = $output;
?>

Any help would be great on this. Thank you in advance.

2
Mithrandir
Re: Php blocks (VWAR)

global $vwardb;
ob_start();
include(
"http://vwar.charlieatsix.com/extra/nextactions.php");
$output ob_get_contents();
ob_end_clean();
$content $output;

You do not need to have <?php and ?> in your php block

But you may not be able to include php files from another site (I don't know if it IS another site)

3
C6Vagabond
Re: Php blocks (VWAR)
  • 2004/10/5 11:25

  • C6Vagabond

  • Just popping in

  • Posts: 3

  • Since: 2004/10/4


I think Ive found the problem.

What if i have several blocks of php scripting mixed with plain html i want to put into the website block?

This is the code:

-
<?php
$vwar_xroot= "absolute path";
$numnextactions= 3;
$showparticipants = 1;
$showirc = 1;
$include = 0;

if( !defined ("VWAR_COMMON_INCLUDED") )
{
$vwar_root = $vwar_xroot;
require_once ($vwar_root . "includes/functions_common.php");
}
if ( $include == 1 )
{
include_once ($vwar_root . "_header.php");
}
updateRepeatingDatelines("vwar".$n, "warid", "dateline", 1, $waroverlap);
?>




<table border="0" cellpadding="0" cellspacing="0" align="center">


<?php
$dateline = (time() - ($waroverlap * 60)) + ($timezoneoffset * 3600);
if (!defined("VWAR_WARS_FROMNOW"))
{
define("VWAR_WARS_FROMNOW", 1);
$result = $vwardb->query_first("
SELECT COUNT(warid) AS numwars
FROM vwar".$n."
WHERE status = '0'
AND dateline > '$dateline'
" . getPublicMatchtypes(1)
);
$num_nextwars = $result['numwars'];
}
if ($num_nextwars > 0)
{
$result=$vwardb->query("
SELECT vwar".$n.".warid, vwar".$n.".gameid, vwar".$n.".gametypeid, vwar".$n.".matchtypeid, status, vwar".$n.".dateline,
oppnameshort, oppircnetwork, oppircchannel, playerperteam, vwar".$n.".oppid, matchtypename, gametypename,
gameicon,gamenameshort
FROM vwar".$n.", vwar".$n."_matchtype, vwar".$n."_gametype, vwar".$n."_opponents, vwar".$n."_games
WHERE vwar".$n.".oppid = vwar".$n."_opponents.oppid
AND vwar".$n.".gametypeid = vwar".$n."_gametype.gametypeid
AND vwar".$n."_matchtype.matchtypeid = vwar".$n.".matchtypeid
AND status = '0' AND vwar".$n.".dateline > '$dateline'
AND vwar".$n.".gameid = vwar".$n."_games.gameid
" . getPublicMatchtypes(1) . "
GROUP BY vwar".$n.".warid
ORDER BY dateline ASC
LIMIT 0, $numnextactions
");

while ($row = $vwardb->fetch_array($result))
{
dbSelect ($row);

if ($row['gameicon'] != "" && file_exists($vwar_root . "images/gameicons/".$row['gameicon']))
{
$gameicon = makeimgtag($urltovwar . "images/gameicons/".$row['gameicon'], $row['gamename']);
}
else
{
$gameicon = "";
}
?>
<tr>
<td align="center">
<?php echo $gameicon; ?>
<!-- gamenameshort start
<?php echo $row['gamenameshort']; ?>:
gamenameshort end -->
<a href="<?php echo $ownhomepage; ?>" target="_blank">
<?php echo $ownnameshort; ?></a> vs. <a href="<?php echo $urltovwar; ?>war.php?action=oppinfo&oppid=<?php echo $row['oppid']; ?>"><?php echo $row['oppnameshort']; ?></a>
</td>
</tr>
<tr>
<td>» <?php echo date($longdateformat, $row['dateline']); ?></td>
</tr>
<!-- details start
<tr>
<td>» <?php echo $row['matchtypename']; ?></td>
</tr>
<tr>
<td>» <?php echo $row['gametypename']; ?></td>
</tr>
details end -->
<?php
if ($showirc == 1 && !empty($row['oppircnetwork']) && !empty($row['oppircchannel']))
{
?>
<tr>
<td>» IRC: <a href="irc://<?php echo $row['oppircnetwork']; ?>/<?php echo $row['oppircchannel']; ?>"><?php echo $row['oppircchannel']; ?></a></td>
</tr>
<?php
}
if ($showparticipants == 1)
{
$result2 = $vwardb->query_first("
SELECT COUNT(partid) AS parts
FROM vwar".$n."_participants
WHERE available = '1'
AND warid = '" . $row['warid'] . "'
");
$parts = $result2['parts'];
?>
<tr>
<td>» Participants: <font color="<?php echo ($parts >= $row['playerperteam']) ? "green" : "red"; ?>"><?php echo $parts." / ".$row['playerperteam']; ?></font></td>
</tr>
<?php
}
?>
<tr>
<td>» <a href="<?php echo $urltovwar; ?>war.php?action=nextaction&formgame=<?php echo $row['gameid']."#".$row['warid']; ?>">details</a><br><br></td>
</tr>
<?php
}
$vwardb->free_result($result);
}
else
{
?>
<tr>
<td align="center">No Next Actions</td>
</tr>
<?php
}
?>
</table>
<?php
if ($include == 1)
{
include_once ($vwar_root . "_footer.php");
}
?>


Anyways its funny because when i copy this text into the block source code and i choose HTML, when i preview it i can see the block working perfectly. When I sumbmit the source code to the DB i cant view the block in the main page as it should show.

4
Mithrandir
Re: Php blocks (VWAR)

which PHP debug errors are you getting?

5
sbkiller
Re: Php blocks (VWAR)
  • 2004/10/5 11:34

  • sbkiller

  • Just can't stay away

  • Posts: 461

  • Since: 2004/6/9 2


Try this way,

without <?php ?> code into your custom block:

include("yourfile.php")

for some reason custom may not always support long php code due to the and it's depend on the php code.

6
C6Vagabond
Re: Php blocks (VWAR)
  • 2004/10/5 16:14

  • C6Vagabond

  • Just popping in

  • Posts: 3

  • Since: 2004/10/4


Ok, problem solved :)

I tried the include("file.php"); without the <?php ?> and it worked.

Thank you very much for the help guys.

Anyways its strange how i could see the code perfectly with the preview code in HTML

Login

Who's Online

114 user(s) are online (90 user(s) are browsing Support Forums)


Members: 0


Guests: 114


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits