Jump to content

Recommended Posts

Ok so I'm helping someone edit a page to show a server checker for a game. As of now I have the code working, but I just need to insert it into the actual page. The person I'm helping is using a portal mod for phpBB. Here is the working code that I have:

 

											<?php
										$fp = fsockopen("68.107.249.246", 10622, $errno, $errstr, 3);
										if (!$fp)
										{
										    echo "Server is DOWN";
										}
										else
										{
										    echo "Server is UP";
										    fclose($fp);
										}
										?>

and here is the entirety of the page:

 

<dt>Games</dt>{$C_BLOCK_H_R}<br/>
<div class="inner">
	<span class="corners-top"><span></span></span>
	<div class="panel bg1">
		<div class="inner"><span class="corners-top"><span></span></span>
			<table border="0" cellpadding="4" cellspacing="1" width="100%" class="forumline">
				<tr>
						<tr>
							<div align=center>
								<tr>
									<td style="width: 10px;" align=center><img src="images/magestorm_icon.jpg"/><br/>Magestorm</td>
									<td style="width: 250px;">
										<br/>
										<?php
										$fp = fsockopen("68.107.249.246", 10622, $errno, $errstr, 3);
										if (!$fp)
										{
										    echo "Server is DOWN";
										}
										else
										{
										    echo "Server is UP";
										    fclose($fp);
										}
										?>
										Magestorm was a game created in 1995 by Mythic Entertainment, which was acquired by Electronic Arts
										in 2006.
										<br/><br/>
										Now that the game is not officially available, we have been working hard to bring it back.
										<br/><br/>
										(This page will go into more detail soon.)
									</td>
									<td style="width: 10px;" class="thTop" align=center nowrap="nowrap"><i>Download Coming Soon</i></td>
								</tr>
							</div>
						</tr>
					</div>
				</tr>
			</table>
		</div>
		<span class="corners-bottom"><span></span></span>
	</div>
</div>
{$C_BLOCK_F_R}

 

edit: I guess I should've mentioned that the PHP doesn't show up at all, just the <br/> but not "Server is UP/DOWN" message.

Link to comment
https://forums.phpfreaks.com/topic/186812-such-a-noob-x/
Share on other sites

Most likely the PHP code is not being parsed and is being put into the page literally. The opening and closing PHP tags will prevent the code from being displayed in the browser, but I'll bet you see the code if you look at the source of the HTML page.

 

Because you are working with a CMS application (i.e. phpBB) you need to be aware of how to include new code. The code you posted above is probably from a template file that is set up in a specific manner to be consumed by the CMS application.

 

Look at the first couple lines:

<dt>Games</dt>{$C_BLOCK_H_R}<br/>
<div class="inner">

 

There is apparently a variable on the first line but that code is not delimited within double quotes of an echo statement, otherwise the the quotes in the second line would screw up the code. It could be that the contents of that file is read into a heredoc container.

 

I don't think you can include PHP code into that file directly. You will need to review the structure of how the files are processed to determine where you can put PHP code to be run. Then assign the output of that code to a variable and then include in that page just like the other variables.

Link to comment
https://forums.phpfreaks.com/topic/186812-such-a-noob-x/#findComment-986529
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.