>>
Site Map
>>
Forums
>>
General 6x
Forum module - topics in forum:
General 6x - Discussions reagarding any other PHP-Nuke Problems.
Trying to get a Java Applet to run as a module
I am trying to get a java applet to run as a module on my website. Its a game called ASteroids. What I am trying to do is to create a module called
Games and when I click on "Games" it then takes me to another page that list all the java games i have but I am not sure how to do it and I was told that the java applet must be called as an html file and not as a php. Can someone help me out on this one? - Please
Thank you
Shedrock
Hey shedrock, am/was doing the same thing, i bet its even the same asteroids game
Abandoned it for the moment as I am trying to get the game to interact with a scoreboard for high scores, dont know enough about aplets yet unfortunitly
If there is any one who reckons they can get the score from the end of this game passed onto another php file from the applet please contact me
Anywho, here is my index file for the module folder, this will look throught the module folder for other folder and list them with a link to the index in the subfolder, so if the module was called Games and a sub folder called Asteroids, a link would apear on the page called Asteroids that links to
modules\Games\Asteroids\index.php. The code is a bit old now but should still work
| Code: : |
if (!eregi("modules.php", $PHP_SELF))
die ("You can't access this file directly...");
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
//get_lang($module_name);
//$pagetitle = "- "._ACTIVETOPICS."";
include("header.php");
$handle=opendir('modules/$module_name');
while ($file = readdir($handle))
{
if ( (!ereg("[.]",$file)) )
{
$modlist .= "$file ";
}
}
closedir($handle);
$modlist = explode(" ", $modlist);
sort($modlist);
for ($i=0; $i < sizeof($modlist); $i++)
{
if($modlist[$i] != "")
{
echo "<A HREF=\"modules\$module_name\$modlist[$i]\index.php\"> $modlist[$i]</A>";
}
}
include("footer.php"); |
And the code for the index.php that is inside the Asteroids folder is
| Code: : |
<?PHP
//No Actuall PHP
?>
<TABLE WIDTH="100%" HEIGHT="100%" ALIGN="CENTER" BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR ALIGN="LEFT" VALIGN="MIDDLE">
<TD ALIGN="CENTER" VALIGN="MIDDLE" COLSPAN="1" ROWSPAN="1">
<APPLET CODE="Asteroids.class" WIDTH=540 HEIGHT=400></APPLET>
</TD>
</TR>
</TABLE> |
Just place all the applet files in the modules/Games/Asteroids folder. The idea was as soon as you add another folder that would apear in the module
See what ya can do 
So where do I place the first index.php file? in the module folder itself of in the games folder? - I tried it both ways and nothing happens. Just a blank screen
Cheers!
Shedrock
Sorry Shedrock was in a ruch out the door when i posted that.
Create a module folder called Games (or indded anything you want), in that folder create an inxed.php an put this in it (some slight changes to the one above)
| Code: : |
<?PHP
if (!eregi("modules.php", $_SERVER[PHP_SELF]))
die ("You can't access this file directly...");
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
include("header.php");
$handle=opendir("modules/".$module_name."");
while ($file = readdir($handle))
{
if ( (!ereg("[.]",$file)) )
{
$modlist .= "$file ";
}
}
closedir($handle);
$modlist = explode(" ", $modlist);
sort($modlist);
for ($i=0; $i < sizeof($modlist); $i++)
{
if($modlist[$i] != "")
{
echo "<A HREF='modules/".$module_name."/".$modlist[$i]."/index.php'> ".$modlist[$i]."</A>";
}
}
include("footer.php");
?> |
Now create the folder modules/Games/Asteroids and place all the asteroids files that are required by the applet in there, also create and index.php file in that folder with the second piece of code I posted above
This works great. Thank you
What I wanted to find out is this. IS there a way to have the game show up in the same window as I did previously instead of selecting a new page and just a white screen? I liked it the way it was on my background colors and the user could still see the main meny options on the left.
Thanks again
Shedrock
Ok, that piece of code works great. The problem I am having is this. I just installed another game which it found in the modules/games folder but in my index.php file which resides in the Games folder I added some lines of text eg: Shedrock's Games Section and on the asteroids game I have an icon to the left of it. Now, as i added the second game it repeated the same text and same icon. So it now says:
Shedrock's Games Section
(theimage) Asteroids
Shedrock's Games Section
(theimage) Shooting
How can I get rid of the duplicate line in there?
Thanks
Shedrock 
Would be easier if you post the code so i can see what you have done
Here it is:
| Code: : |
<?PHP
if (!eregi("modules.php", $_SERVER[PHP_SELF]))
die ("You can't access this file directly...");
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
include("header.php");
$handle=opendir("modules/".$module_name."");
while ($file = readdir($handle))
{
if ( (!ereg("[.]",$file)) )
{
$modlist .= "$file ";
}
}
closedir($handle);
$modlist = explode(" ", $modlist);
sort($modlist);
for ($i=0; $i < sizeof($modlist); $i++)
{
if($modlist[$i] != "")
{
echo " ";
echo"<center><p><b>Welcome to the Games Area on Shedrock.com</p></b></center><BR><BR>\n";
echo "<center><img border=\"0\" src=\"images/games/asteroids.gif\" width=\"25\" height=\"26\"><A HREF='modules/".$module_name."/".$modlist[$i]."/index.php'> ".$modlist[$i]."</A></center>";
}
}
include("footer.php");
?> |
OK, you have placed the header in between the loop {} that is why it is being repeated, evetything inside tohse {} will be repeaated for every game. Which is what you want for the image and name but not the header so use this :
| Code: : |
<?PHP
if (!eregi("modules.php", $_SERVER[PHP_SELF]))
die ("You can't access this file directly...");
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
include("header.php");
echo " ";
echo"<center><p><b>Welcome to the Games Area on Shedrock.com</p></b></center><BR><BR>\n";
$handle=opendir("modules/".$module_name."");
while ($file = readdir($handle))
{
if ( (!ereg("[.]",$file)) )
{
$modlist .= "$file ";
}
}
closedir($handle);
$modlist = explode(" ", $modlist);
sort($modlist);
for ($i=0; $i < sizeof($modlist); $i++)
{
if($modlist[$i] != "")
{
echo "<center><img border=\"0\" src=\"images/games/asteroids.gif\" width=\"25\" height=\"26\"><A HREF='modules/".$module_name."/".$modlist[$i]."/index.php'> ".$modlist[$i]."</A></center>";
}
}
include("footer.php");
?> |
Also you have the image as asteroids.gif, you cant do that casue it needs to be dynamic other wise all the images will be asteroids.gif, to use the name of the folder (ie Asteroids) used this
| Code: : |
| echo "<center><img border=\"0\" src=\"images/games/".$modlist[$i].".gif\" width=\"25\" height=\"26\"> |
So just put an image in the games directory called the same name as the sub directorys.gif
Damn, you're good. Don't know how you guys figure this stuff out. But sure glad you do.
Thanks a million Dashe.
Shedrock 