Visualizzazione risultati 1 fino 5 di 5

Discussione: problema modulo giochi

  1. #1
    Guest

    Post problema modulo giochi

    Ho delle difficoltà a far funzionare GArcade, un modulo giochi per PHP-Nuke.
    Il problema sta nel fatto che dovrebbe usare fopen per leggere un file .txt interno, ma il safe mode glielo impedisce.
    Ho cercato di fare alcune modifiche al codice, ma solitamente ho a che fare con c# !

    Per favore qualcuno che sa il php mi dia una mano...
    ... e posterò il codice.

  2. #2
    Guest

    Post Codice I

    La 1° parte:
    <?php
    /* The Ghettronix Online Game Arcade
    Author: Zoid
    Website: http://www.zoid.tk/
    Released: December 28, 2004
    Version: Hasn't reached 1.0

    *** SEE README.TXT INCLUDED WITH THIS PACKAGE ***

    ************************************************** *****************************
    ** BUGS ************************************************** *********************
    ************************************************** *****************************
    Send any bug reports to zoid ( see contact info below or visit http://zoid.tk/ )

    * Known Bugs/Problems:
    - An extra character is read from the description and is placed in another
    array, which affects the next game in the index. Only known to happen when only
    one game is loaded.
    - Inefficiency caused by reading the entire TXT file, when not all of it is
    needed. (commented twice on this script)
    - Background on all SWF files is set to black, it may need to be specifiable
    in the data.txt in order to work properly on various games.

    ************************************************** ****************************
    ** CONTACT ************************************************** *****************
    ************************************************** ****************************
    -ZOID-
    Email: zoid@jlmail.com
    AIM: It Sux 4 U
    Website: http://www.zoid.tk/

    ************************************************** ****************************
    © Copyright 2004 Ghettronix
    All Rights Reserved
    */



    if (!eregi("modules.php", $PHP_SELF)) {
    die ("You can't access this file directly...");
    }
    require_once("mainfile.php");
    $module_name = basename(dirname(__FILE__));
    include("header.php");
    if ( strip_tags($_GET['game']) == "" ) { $index = 1; } else { $index = 0; }
    OpenTable();
    // --------------------------------------------------------------------------
    // ***VAR CONFIG***
    $perpage = 8; // How many to have per page
    $perrow = 4; // How many columns to show in grid mode
    $viewpref = "choose"; // The option to enable/disable different games list view stypes (a.k.a. indexstyle). Current options listed below:
    /* Variable option: What it does:
    "choose" gives users the option to pick their GArcade list page style, but by default shows the regular list with descriptions.
    "list" forces users view the games list page-by-page with descriptions for each style. The option to view as grid style is removed.Iif you access the URL of the grid style page, it will still force this indexstyle on the user.
    "grid" Just like "list," except it forces users onto the grid view. Decriptions are not displayed, and every game is visible on one single page. */
    $showbutton = "yes"; // display the button link to Ghettronix at the end of each page.
    echo "<center><image src=\"modules/GArcade/images/title.gif\" width=\"200\" height=\"72\" alt=\"Games Arcade\"><br>Games Arcade<br>"; // The Title Image
    // --------------------------------------------------------------------------
    $pg = strip_tags($_GET['pg']); //Get what page we're on
    $game = strip_tags($_GET['game']);
    if ( $viewpref == "choose" || $viewpref == "" ) { // toggle $viewpref and the user's chosen style to view the games index listing.
    $indexstyle = $_GET['indexstyle']; // get what index style the user has chosen.
    } elseif ( $viewpref == "list" ) {
    $indexstyle = ""; // force the list index style onto the user (see variable config for description of this function).
    } elseif ( $viewpref == "grid" ) {
    $indexstyle = "grid"; // force the grid index style onto the user (see variable config for a description of this function).
    } //end $viewpref toggle thing.

    if ( $game == "" ) { // when $game == "" it's time to index all the games :)
    // ------------------------
    // get contents of txt file into an array. *THIS PART COULD USE SOME INCREASED EFFICIENCY* it'd be nice if it didnt have to load the entire text file.
    $filename = $_SERVER['DOCUMENT_ROOT'].str_replace("modules.php","",$_SERVER['SCRIPT_NAME'])."modules/GArcade/gamedat/data.txt";
    $handle = fopen($filename, "r");
    if (!$handle) {
    echo "Error opening data file. Check to see if the file exists.";
    exit;
    }
    while (!feof($handle)) { $contents[] = fgets($handle, filesize($filename)); }
    fclose($handle);
    $howmany = count($contents); // find out how many games there are total
    // each line of txt file was turned into a string in the array $contents

    // The Title string, like the McDonalds "#### Served" sign:
    echo "<br>Now Serving <b>$howmany</b> Games.<br>Select from the games listed below:";
    echo "</center>";

    if ($indexstyle == "") {
    echo "<center><table border=\"0\" width=\"100%\">"; // You gotta start the table, right? How else can you contain the index?
    } elseif ( $indexstyle == "grid" ) {
    echo "<center><table border=\"0\">"; // if youre using the grid index style, you dont want width=100%, cuz that could look ugly.
    }

    if ( $indexstyle == "grid" ) { $perpage = $howmany; } // If you are using the GRID style, you want all the games to fit on a grid on one page, so you need to remove the limit on how many games are displayed on one page (so that all games are on one page).
    for($i = ( 0 + ( $pg * $perpage ) ); $i < ( $perpage *( $pg + 1 ) ); $i++) { //this is the loop that will be run to generate the games index
    // ---loop index---
    $gameData = explode("||",$contents[$i]); // rip apart the $i string of the array into its own array
    // Set up all vars with info needed for indexing:
    $gameTitle = $gameData[0];
    $gameThumb = $gameData[1];
    if ($indexstyle == "") {
    $gameDesc = $gameData[6];
    }

    // these vars aren't needed for indexing, but are left here for reference:
    //$gameType = $gameData[2]; // ex: swf
    //$gameFile = $gameData[3]; // ex: snake.swf
    //$gameWidth = $gameData[4];
    //$gameHeight = $gameData[5];

    if ($i > ( $howmany - 1 )) { // All the links that show up on the index but don't correspond to a game are set to "Not Available"
    $gameTitle = "Not Available";
    $gameThumb = "unavailable.gif";
    $gameDesc = "This game is not available.";
    }

    // Do the actual indexing, loop it and switch between formats depending on if $i is even or odd:
    if ($indexstyle == "") {
    if ( $i&1 ) {
    $gameTitle = str_replace(array("_", "-"), " ", $gameTitle);
    echo "<tr bgcolor=\"#F0F0F0\"><td colspan=\"2\" width=\"100%\" align=\"right\"><a href=\"modules.php?name=GArcade&game=".($i + 1)."&pg=".$pg."\"><p style=\"text-transform: capitalize\"><b>".$gameTitle."</b> #".($i + 1)."</p><p>".$gameDesc."</p></a></td><td width=\"70\"><a href=\"modules.php?name=GArcade&game=".($i + 1)."&pg=".$pg."\"><img src=\"modules/GArcade/gamedat/thumbnails/".$gameThumb."\" width=\"70\" height=\"59\" border=\"0\"></a></td></tr>";
    } else {
    $gameTitle = str_replace(array("_", "-"), " ", $gameTitle);
    echo "<tr bgcolor=\"#E0E0E0\"><td width=\"70\"><a href=\"modules.php?name=GArcade&game=".($i + 1)."&pg=".$pg."\"><img src=\"modules/GArcade/gamedat/thumbnails/".$gameThumb."\" width=\"70\" height=\"59\" border=\"0\"></a></td><td colspan=\"2\" width=\"100%\" align=\"left\"><a href=\"modules.php?name=GArcade&game=".($i + 1)."&pg=".$pg."\"><p style=\"text-transform: capitalize\"><b>".$gameTitle."</b> #".($i + 1)."</p><p>".$gameDesc."</p></a></td></tr>";
    }
    } elseif ($indexstyle == "grid") {


    if ( !isset($gridvar1) ) { $gridvar1 = 0; } // define $gridvar1 (the variable which counts how many cells per row have been created) as 0 if not already defined.
    if ( $gridvar1 == 0 ) {
    echo "<tr>";
    }
    $gameTitle = str_replace(array("_", "-"), " ", $gameTitle);
    if ( $i&1 ) {
    echo "<td width=\"70\" bgcolor=\"#F0F0F0\" align=\"center\"><a href=\"modules.php?name=GArcade&indexstyle=grid&ga me=".($i + 1)."\"><img src=\"modules/GArcade/gamedat/thumbnails/".$gameThumb."\" width=\"70\" height=\"59\" border=\"0\"><p style=\"text-transform: capitalize\"><b>".$gameTitle."</b></p></a></td>\n";
    } else {
    echo "<td width=\"70\" bgcolor=\"#E0E0E0\" align=\"center\"><a href=\"modules.php?name=GArcade&indexstyle=grid&ga me=".($i + 1)."\"><img src=\"modules/GArcade/gamedat/thumbnails/".$gameThumb."\" width=\"70\" height=\"59\" border=\"0\"><p style=\"text-transform: capitalize\"><b>".$gameTitle."</b></p></a></td>\n";
    }
    $gridvar1 = ($gridvar1 + 1);
    if ( ($gridvar1 == $perrow) || ($i == $howmany) ) {
    echo "</tr>";
    $gridvar1 = 0;
    }

    } else {
    echo "There was an error in choosing your view type. If the problem persists, please report this error to this website's administrator along with the URL you were trying to reach.<Br><br>More information about this error: check the indexstyle variable in this page's GET command (look in the URL somewhere after the question mark).";
    }


  3. #3
    Guest

    Post Codice II

    Ecco la 2° parte:
    //These were used to test that things were working along the way:
    //echo $gameTitle;
    //echo $gameDesc;
    //echo $i;
    //echo $contents[$i];
    //print_r($gameData);
    //echo "<br>";

    // ---loop index---
    }
    // ------------------------

    if ($indexstyle == "") { echo "<tr><td></td><td width=\"100%\" align=\"center\"><br>&nbsp;</td><td></td></tr>"; }
    echo "</table></center>";

    if ( $indexstyle == "" ) { /* PAGES LIST BEGIN */
    //echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">";
    //echo "<tr><td></td><td width=\"100%\" align=\"center\">";
    echo "<br><center>Pages:<br>";
    if ( $pg > 0 ) { echo "<a href=\"modules.php?name=GArcade&pg=".( $pg - 1 )."\">« Back</a>&nbsp;"; }
    $howmanypages = ceil( $howmany / $perpage );
    for( $i = 1 ; $i <= $howmanypages ; $i++ ) {
    echo "&nbsp;";
    if ( $i != ( $pg + 1 ) ) {
    echo "<a href=\"modules.php?name=GArcade&pg=".( $i - 1 )."\">".$i."</a>";
    } else {
    echo "[".$i."]";
    }
    echo "&nbsp;";
    }
    if ( ( $pg+ 1 ) < $howmanypages ) { echo "&nbsp;<a href=\"modules.php?name=GArcade&pg=".( $pg + 1 )."\">Next »</a>"; }

    echo "</center>";

    //echo "</td><td></td></tr>";
    //echo "</table>";
    } /* PAGES LIST END */

    if ( $viewpref == "choose" ) {
    if ( $indexstyle == "" ) {
    echo "<br><p align=\"right\"><B><a href=\"modules.php?name=GArcade&indexstyle=grid\"> Grid View</a></B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>";
    } elseif ( $indexstyle == "grid" ) {
    echo "<br><p align=\"right\"><B><a href=\"modules.php?name=GArcade&indexstyle=\">List View</a></B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>";
    }
    }


    echo "<br><br><center>";
    echo "<a href=\"http://www.macromedia.com/go/shockwaveplayer/\" target=\"_blank\"><img src=\"modules/GArcade/images/get_shockwave.gif\" width=\"88\" height=\"31\" border=\"0\"></a>";
    echo "&nbsp;<a href=\"http://www.macromedia.com/go/getflashplayer/\" target=\"_blank\"><img src=\"modules/GArcade/images/get_flashplayer.gif\" width=\"88\" height=\"31\" border=\"0\"></a>";
    echo "</center>";
    // --------------------------------------------------------------------------
    } else {
    // GAME PLAY SCREEN:

    $gameid = strip_tags($_GET['game']); // take the $gameid from the GET method, but don't forget to subtract 1 (which was added earlier for usage purposes)

    $pg = strip_tags($_GET['pg']); // get what page the user came from, so we can have the "Go Back" link return to that page number.

    $indexstyle = strip_tags($_GET['indexstyle']); // get what index list style was used in the page the user came from, so the "Go Back" link can return to that page style.

    // get contents of txt file into an array. *THIS PART COULD USE SOME INCREASED EFFICIENCY* it'd be nice if it didnt have to load the entire text file.
    $filename = $_SERVER['DOCUMENT_ROOT'].str_replace("modules.php","",$_SERVER['SCRIPT_NAME'])."modules/GArcade/gamedat/data.txt";
    $handle = fopen($filename, "r");
    if (!$handle) {
    echo "Error opening data file.";
    exit;
    }
    while (!feof($handle)) { $contents[] = fgets($handle, filesize($filename)); }
    fclose($handle);
    // each line of txt file was turned into a string in the array $contents

    // Set vars with data specific to the game to be loaded and played:
    $gameData = explode("||",$contents[($gameid-1)]);
    $gameTitle = $gameData[0];
    $gameType = $gameData[2]; // ex: swf
    $gameFile = $gameData[3]; // ex: snake.swf
    $gameWidth = $gameData[4];
    $gameHeight = $gameData[5];
    //$gameThumb = $gameData[1]; //This one isn't needed here. :P
    //$gameDesc = $gameData[6]; //This one isn't needed here. :P

    $gameTitle = str_replace(array("_", "-"), " ", $gameTitle); // just a little transformation of the title for clarity, however it is not necessary.

    // In case there is no game, it will be titled as "Not Available":
    $howmany = count($contents); // find out how many games there are total
    if ($gameid > $howmany) {
    $gameTitle = "Not Available";
    $gameType = "n/a";
    }

    // Here is a title string for under the Title Image:
    echo "<p style=\"text-transform: capitalize\">";
    echo "<b>Now Playing: ";
    echo $gameTitle;
    echo "</b>";
    echo "</p>";

    if ( stristr($gameFile, 'http://') == false ) { // If the swf file in data.txt is a URL (begins w/ http://), don't mess with it.
    $gameLink = "modules/GArcade/gamedat/gamefiles/".$gameFile; // set the path to the file
    } else {
    $gameLink = $gameFile;
    }


    if ($gameType == "swf") { // If the game is an SWF (flash) file.
    // SWF OBJECT START


    echo "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"".$gameWidth."\" height=\"".$gameHeight."\" id=\"".$gameTitle."\" align=\"middle\" data=\"".$gameLink."\">";
    echo "<param name=\"allowScriptAccess\" value=\"sameDomain\" />";
    echo "<param name=\"movie\" value=\"".$gameLink."\" />";
    echo "<param name=\"quality\" value=\"high\" />";
    echo "<param name=\"bgcolor\" value=\"#000000\" />";
    echo "<embed src=\"".$gameLink."\" quality=\"high\" bgcolor=\"#000000\" width=\"".$gameWidth."\" height=\"".$gameHeight."\" name=\"".$gameTitle."\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /></embed>";
    echo "</object><br>";
    // SWF OBJECT END
    //} elseif ($gameType == "java") {
    //echo $gameFile;
    } elseif ($gameType == "n/a") {
    echo "<big>This game is Unavailable. You may <a href=\"modules.php?name=GArcade&game=&pg=".$pg."&i ndexstyle=".$indexstyle."\">Go Back</a> and choose another game.</big>";
    }
    // ------end of play screen---
    echo "<br><hr><br><a href=\"modules.php?name=GArcade&game=&pg=".$pg."&i ndexstyle=".$indexstyle."\">Back To Arcade</a>";
    echo "</center>";
    }
    // --------------------------------------------------------------------------
    echo "<hr><div align=\"right\"><a href=\"http://www.zoid.tk/\" target=\"_blank\">Developed for the Ghettronix Online Community</a></div>"; // Copyright Info
    CloseTable();
    if ($showbutton == "yes") {
    echo "<br><br><br>";
    echo "<center><a href=\"http://www.zoid.tk\" target=\"_blank\"><img src=\"modules/GArcade/images/zoidbutton.gif\" width=\"88\" height=\"31\" border=\"0\"><br>Ghettronix<br>http://www.zoid.tk/</a></center>";
    }
    include("footer.php");
    ?>

  4. #4
    Guest

    Predefinito

    Non preoccupatevi, ho risolto autonomamente.

  5. #5
    Ospite Guest

    Predefinito

    cmq il safe mode non impedisce di leggere un file , al massimo impedisce di aprire file al di fuori dal proprio spazio

Regole di scrittura

  • Non puoi creare nuove discussioni
  • Non puoi rispondere ai messaggi
  • Non puoi inserire allegati.
  • Non puoi modificare i tuoi messaggi
  •