1
jimbofoxman
Including external php file?

Is there a way to include an external php file into an XOOPS block, or module or something?

I have this php file that includes a bunch of images.

For the file structure..

Root
 
-mohaa.php
 
-[IMAGES DIR]
    -
image1.jpg
         
.
         .
    -
imagex.jpg

So I placed it in a seperate folder

My Root
 
-[Xoops Dir]
 -[
OtherModules Dir]
   -[
mohaastat Dir]
     -
mohaa.php
     
-[images dir]
       -
image1.jpg
       
-image2.jpg
             
.
             .
       -
imagex.jpg

So how could I call that mohaa.php file into a block?

<?php
if (!$_GET['server']) { 
$server_ip "69.56.150.243"// the ip of the server which stats are shown
$server_port "12203"// the port of the server which stats are shown
} else { 
$server explode(":"$_GET['server']); 
$server_ip $server[0]; 
$server_port $server[1]; 
}
$server_ip "udp://" $server_ip;
$connect fsockopen($server_ip$server_port$errno$errstr30); 
if (
$connect) {
socket_set_timeout ($connect1000000);

$send "ÿÿÿÿ" chr (0x02) . "getstatus"
fputs($connect$send); 
fwrite ($connect$send); 
$output fread ($connect1); 
if (! empty (
$output)) { 
   do { 
     
$status_pre socket_get_status ($connect); 
     
$output $output fread ($connect1); 
     
$status_post socket_get_status ($connect); 
   } while (
$status_pre[unread_bytes] != $status_post[unread_bytes]); 
};
fclose($connect);
$output explode ("\"$output); 

$max_index array_search ("sv_maxclients"$output); 
$max_clients $output[$max_index+1]; 

$max_index array_search ("mapname"$output); 
$mapname $output[$max_index+1]; 

$max_index array_search ("sv_hostname"$output); 
$hostname $output[$max_index+1]; 

$max_index array_search ("g_gametypestring"$output); 
$gametype $output[$max_index+1]; 

$last_value count($output) - 1
$players_string $output[$last_value]; 
$players_string explode(""", $players_string); 

$get_first_ping = explode("n", $players_string[0]); 
$players_string[0] = $get_first_ping[1]

$i = 1; 
$players = 0; 
while (count(
$players_string) != $i) { 
$i++; 
$i++; 
$players++; 
}
if (substr(
$mapname, 0, 3) == "dm/") { 
$picture_src = str_replace("dm/", "", $mapname); 
} else { 
$picture_src = str_replace("obj/", "", $mapname); 

$picture_src = "images/" . $picture_src . ".jpg"; // path to the map-pictures
}
if (!file_exists(
$picture_src)) {
   
$picture_src = "images/no_image.jpg"; // image to display when there's no image of the current map
}
if (!
$max_clients) { 
?> 
<html> 
<head>
</head> 
<body bgcolor="
#20203F"> 
<table align="center" bgcolor="#20203F"
<
tr
<
td><p align="center"><img src="images/offline.jpg" border="1"></p></td>
</
tr
</
table
</
body
</
html
<? 
exit; 
}
?> 
<html> 
<head>
<style type="text/css">
TD { font-family: Verdana; font-size: 10pt }
</style> 
</head> 
<body bgcolor="#20203F"> 
<table width="600" border="0" align="center"> 
<caption><font face="Verdana" color="#FFFFFF"><b><?=$hostname?></b></font></caption> 
<tr> 
    <td width="256" valign="top"> 
    <table border="0"> 
         <tr> 
             <td width="256"><font color="#587ea5">Gametype: <?=$gametype?></font><td> 
         </tr> 
         <tr> 
             <td width="256"><font color="#587ea5">Players: <?=$players?>/<?=$max_clients?></font></td> 
         </tr> 
         <tr> 
             <td width="256"><font color="#587ea5">Map: <?=$mapname?></font></td> 
         </tr> 
         <tr> 
             <td width="256"><img src="<?=$picture_src?>" border="1" width="200" height="150"></td> 
         </tr> 
    </table> 
    </td> 
    <td valign="top"> 
        <table border="0"> 
        <tr> 
            <td width="300"><font color="#587ea5"><b>Name</b></font></td> 
            <td width="44"><font color="#587ea5"><b>Ping</b></font></td> 
        </tr> 
        <? 
        $i = 1; 
        while (count($players_string) != $i) { 
        $j = $i -1; 
        ?> 
        <tr> 
            <td width="300"><font color="#FFFFFF">
                <?=$players_string[$i]?> 
            </font></td> 
            <td width="44"><font color="#FFFFFF"> 
                <?=$players_string[$j]?> 
            </font></td> 
        </tr> 
        <? 
        $i = $i + 2; 
        } 
    ?> 
    </table> 
    </td> 
</tr> 
</table> 
</body> 
</html>

2
Lance_
Re: Including external php file?
  • 2006/1/11 0:55

  • Lance_

  • Home away from home

  • Posts: 983

  • Since: 2004/1/12


The myiframe module.
GDL-Web.com :: Website development.
Xoopslance.com::Freelancing and Projects
thelionsden-arena.net:: Clan/League/Ladder Hosting

3
jimbofoxman
Re: Including external php file?

Now what about putting that in a block instead of as if it were a module?

4
Anonymous
Re: Including external php file?
  • 2006/1/11 1:38

  • Anonymous

  • Posts: 0

  • Since: 0


Hi,

Go to admin panel >> Blocks >> New Block ( at the end of page ) then include your php file as the following:

include(XOOPS_ROOT_PATH."/mohaa.php");

Remember to select PHP from dropdown menu and upload mohaa.php to root folder.


5
Will_H
Re: Including external php file?
  • 2006/1/11 3:23

  • Will_H

  • Friend of XOOPS

  • Posts: 1786

  • Since: 2004/10/10


you said it was external right? as in, not on your webserver...

in my opinion the easiest way to do this is to use <iframe> code

6
jimbofoxman
Re: Including external php file?

Ok, it's external to xoops, but not external to my site. Slight misuse of the term external. LOL