Fork me on GitHub

Problem with a module Game_Cheats  Bottom

  • My friend make a module allowing us to put on game cheats, its called Game_Cheats lol. anyways here is our problem, first off it only allows 5 cheats displayed at a time and at the bottom it shows like 1-10 pages to scroll thru, we want to change this so it can all be on 1 long page, secondly, whenever we type in the letter, then select the game, and lets say there is 12 cheats, it displays 5 on 1 page, but when u select another page it just puts u back to the main cheats page, any help? :(
  • here is the code:

    Code

    <?PHP

    function game_cheats_user_main()
    {
        $output = new pnHTML();

        if (!pnSecAuthAction(0, 'Game_Cheats::', '::', ACCESS_OVERVIEW)) {
            $output->Text(_GAMECHEATS_NOAUTH);
            return $output->GetOutput();
        }

        $output->SetInputMode(_PNH_VERBATIMINPUT);
        $output->Text(game_cheats_usermenu());
        $output->SetInputMode(_PNH_PARSEINPUT);

        // Return the output that has been generated by this function
        return $output->GetOutput();
    }

    function alpha($output){
        // Creates the list of letters and makes them a link.
        $alphabet = array (_ALL, "A","B","C","D","E","F","G","H","I","J",
                                 "K","L","M", "N","O","P","Q","R","S","T",
                                 "U","V","W","X","Y","Z");
        $num = count($alphabet) - 1;
        $authid = pnSecGenAuthKey();
        $counter = 0;
        $result = "[";

        $output->SetOutputMode(_PNH_RETURNOUTPUT);
        $output->SetInputMode(_PNH_PARSEINPUT);
        while(list(, $ltr) = each($alphabet)) {

            $result .=  $output->URL(pnVarPrepForDisplay(
                                 pnModURL('Game_Cheats',
                                      'user',
                                      'view_games',
                                      array('letter' => $ltr))), $ltr);
            if ($counter == round($num/2)) {
                $result .= " ]\n<br>\n[ ";
            } elseif($counter != $num) {
                $result .=  "&nbsp;|&nbsp;\n";
            }
            $counter++;
        }
        $output->SetOutputMode(_PNH_KEEPOUTPUT);

        $result .=  " ]\n<br>\n";
        return $result;
    }

    function game_cheats_user_view_games($args)
    {
        $startnum = pnVarCleanFromInput('startnum');
        $letter = pnVarCleanFromInput('letter');

        $output = new pnHTML();

        $output->SetInputMode(_PNH_VERBATIMINPUT);
        $output->Text(game_cheats_usermenu());
        $output->SetInputMode(_PNH_PARSEINPUT);

        if (!pnSecAuthAction(0, 'Game_Cheats::', '::', ACCESS_OVERVIEW)) {
            $output->Text(_GAMECHEATS_NOAUTH);
            return $output->GetOutput();
        }

        $numitems = 3;

        if (!isset($letter))
            $letter = '';
        if ($letter == 'All')
            $letter = '';
        if (!pnModAPILoad('Game_Cheats', 'user')) {
            $output->Text(_LOADFAILED);
            return $output->GetOutput();
        }
        $games = pnModAPIFunc('Game_Cheats',
                               'user',
                               'get_games',
                               array('letter'   => $letter,
                                     'startnum' => $startnum,
                                     'numitems' => $numitems ));
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        $output->Linebreak(1);
        if ($letter != '') {
            $output->Text("<div>" . _GAMECHEATS_GAMES_LETTER . ": ");
            $output->BoldText($letter);
            $output->Text("</div>");
        } else {
            $output->Text("<div>" . _GAMECHEATS_GAMES_ALL . ": ");
        }
        $output->SetInputMode(_PNH_PARSEINPUT);
        $output->Linebreak(1);

        if ($games == false) {
            if ($letter != '')
                $output->Text(_GAMECHEATS_NOGAMESLETTER);
            else
                $output->Text(_GAMECHEATS_NONE);
        } else {
            $output->Linebreak(1);
            foreach ($games as $game) {

                $link_name = "{$game['game']} ({$game['cheats']})";
                $link_name = pnVarPrepForDisplay(pnVarCensor($link_name));
                $output->URL(pnVarPrepForDisplay(
                                     pnModURL('Game_Cheats',
                                          'user',
                                          'view_cheats',
                                          array('game' => $game['game']))),
                                          $link_name);
                $output->Linebreak();
            }
        }
        $output->Linebreak(2);

        $output->Pager($startnum,
                      pnModAPIFunc('Game_Cheats', 'user', 'countgames',
                                   array('letter' => $letter)),
                             pnModURL('Game_Cheats',
                                      'user',
                                      'view_games',
                                      array('letter' => $letter,
                                            'startnum' => '%%')),
                                            $numitems);
        return $output->GetOutput();
    }

    /**
     * View cheats.
     *
     * This is a function to provide an overview of:
     * - all the cheats
     * - all cheats for a given game (if the argument is specified)
     */

    function game_cheats_user_view_cheats()
    {
        $in_startnum = pnVarCleanFromInput('startnum');
        $in_game     = pnVarCleanFromInput('game');

        include 'header.php';

        echo game_cheats_usermenu();

        $output = new pnHTML();
        $output->SetInputMode(_PNH_PARSEINPUT);

        // Security check - important to do this as early as possible to avoid
        // potential security holes or just too much wasted processing
        if (!pnSecAuthAction(0, 'Game_Cheats::', '::', ACCESS_OVERVIEW)) {
            echo _GAMECHEATS_NOAUTH;
            include 'footer.php';
            exit;
        }

        $numitems = 5;

        if (!pnModAPILoad('Game_Cheats', 'user')) {
            echo _LOADFAILED;
            include 'footer.php';
            exit;
        }


        $cheats = pnModAPIFunc('Game_Cheats',
                               'user',
                               'get_cheats',
                               array('game'     => $in_game,
                                     'startnum' => $in_startnum,
                                     'numitems' => $numitems ));

        if (count($cheats) == 0) {
            echo _GAMECHEATS_NONE;
            include 'footer.php';
            exit;
        }

        if ($cheats == false) {
            echo _GAMECHEATS_GETCHEATSFAILED;
            include 'footer.php';
            exit;
        }

        echo '<br>';

        $headers = array(_GAMECHEATS_ID, _GAMECHEATS_PLATFORM,
                         _GAMECHEATS_CHEAT);

        $title  = ($in_game == '') ? _GAMECHEATS_LATEST
                                   : _GAMECHEATS_FOR_GAME . " '"
                                   . $in_game . "'";


        $bgcolor1 = $GLOBALS['bgcolor1'];
        $bgcolor2 = $GLOBALS['bgcolor2'];

        echo "<table width=\"95%\" bgcolor=\"$bgcolor1\" border=\"1\" cellpadding=\"5\">";
        echo "<tr bgcolor=\"$bgcolor2\">",
             "<th>Game</th><th>Platform</th><th>Cheat</th></tr>";

        foreach ($cheats as $cheat) {
           
            $output->SetOutputMode(_PNH_RETURNOUTPUT);
            $game     = strtoupper($output->Text(pnVarCensor($cheat['game'])));
            $platform = $output->Text(pnVarCensor($cheat['platform']));
            $link     = $output->URL(pnVarPrepForDisplay(
                             pnModURL('Game_Cheats',
                                      'user',
                                      'display_cheat2',
                                      array('id' => $cheat['id']))),
                             pnVarPrepForDisplay(pnVarCensor($cheat['cheat'])));
            echo "<tr bgcolor\"$bgcolor2\" valign=\"top\">",
                 "<td nowrap>$game</td><td>$platform</td><td>$link</td></tr>";
        }

        echo "</table>";

        $output->SetOutputMode(_PNH_RETURNOUTPUT);

        // setup the pager:
        echo "<br>";

        echo $output->Pager($in_startnum,
                      pnModAPIFunc('Game_Cheats', 'user', 'countcheats',
                                   array('game' => $in_game)),
                             pnModURL('Game_Cheats',
                                      'user',
                                      'view_cheats',
                                      array('startnum' => '%%')), $numitems);
        include ('footer.php');
        exit;
    }

    /**
     * display a cheat
     */

    function game_cheats_user_display_cheat2($args)
    {
        extract($args);

        $id = pnVarCleanFromInput('id');

        include("header.php");

        echo game_cheats_usermenu();

        if (!pnSecAuthAction(0, 'Game_Cheats::', '::', ACCESS_READ)) {
            echo _GAMECHEATS_NOAUTH;
            include 'footer.php';
            exit;
        }

        if (!pnModAPILoad('Game_Cheats', 'user')) {
            echo _LOADFAILED;
            include 'footer.php';
            exit;
        }

        $cheat = pnModAPIFunc('Game_Cheats', 'user', 'get_cheat',
                               array('id' => $id));
        if ($cheat == false) {
            echo _GAMECHEATS_NOSUCHCHEAT;
            include 'footer.php';
            exit;
        }

        $bgcolor1 = $GLOBALS['bgcolor1'];
        $bgcolor2 = $GLOBALS['bgcolor2'];

        $upper_game = strtoupper($cheat['game']);

        $output = new pnHTML();
        $output->SetOutputMode(_PNH_RETURNOUTPUT);

        echo "<br><table border=\"1\" cellspacing=\"0\" cellpadding=\"4\"",
                  " width=\"95%\" align=\"center\" ",
             " bgcolor=\"$bgcolor2\">",
             "<tr bgcolor=\"$bgcolor1\">",
             "<th bgcolor=\"$bgcolor2\" align=\"right\" width=\"30%\">",
             (_GAMECHEATS_GAME . ':'), "</th>",
             "<td align=\"center\"><font \"PN-normal\" size=\"2\">",
             "<b>$upper_game</b></font></td></tr>",
             "<tr bgcolor=\"$bgcolor1\">",
             "<th bgcolor=\"$bgcolor2\" align=\"right\">",
             (_GAMECHEATS_PLATFORM . ':'), "</th>",
             "<td><font class=\"PN-normal\"><I>{$cheat['platform']}</I>",
             "</font></td>",
             "</tr>",
             "<tr bgcolor=\"$bgcolor1\">",
             "<th bgcolor=\"$bgcolor2\", align=\"right\">",
             (_GAMECHEATS_CHEAT . ':'), "</th>",
             "<td valign=\"top\"><font class=\"PN-normal\">",
              "{$cheat['cheat']}</font></td>",
             "</tr>",
             "<tr bgcolor=\"$bgcolor1\" valign=\"top\">",
             "<th bgcolor=\"$bgcolor2\" align=\"right\">",
             (_GAMECHEATS_CHEAT_WHERE . ':'), "</th>",
             "<td><font class=\"PN-normal\">{$cheat['where']}&nbsp;</font></td>",
             "</tr>",
             "<tr bgcolor=\"$bgcolor1\">",
             "<th bgcolor=\"$bgcolor2\" align=\"right\">",
             (_GAMECHEATS_CHEAT_RESULTS . ':'), "</th>",
             "<td valign=\"top\"><font class=\"PN-normal\">",
             "{$cheat['results']}&nbsp;</font></td>",
             "</tr>";

        // for an admin - add 'edit' and 'delete' buttons:
        if (pnSecAuthAction(0, 'Game_Cheats::Cheat', '::', ACCESS_EDIT)) {
            $form = $output->FormStart(pnModURL('Game_Cheats', 'admin',
                                       'cheat_edit'));
            $form .= $output->FormSubmit(_GAMECHEATS_CHEATEDIT);
            $form .= $output->FormHidden('authid', pnSecGenAuthKey());
            $form .= $output->FormHidden('id', $id);
            $form .= $output->FormEnd();

            echo "<tr><td align=\"center\">$form</td></tr>";
        }
        if (pnSecAuthAction(0, 'Game_Cheats::Cheat', '::', ACCESS_DELETE)) {
            $form = $output->FormStart(pnModURL('Game_Cheats', 'admin',
                                       'cheat_delete'));
            $form .= $output->FormSubmit(_GAMECHEATS_CHEATDELETE);
            $form .= $output->FormHidden('authid', pnSecGenAuthKey());
            $form .= $output->FormHidden('id', $id);
            $form .= $output->FormEnd();
            echo "<tr><td align=\"center\">$form</td></tr>";
        }


        echo "</table>";

        include("footer.php");
        return true;
    }

    /**
     * display a cheat
     */

    function game_cheats_user_display_cheat($args)
    {
        extract($args);

        $id = pnVarCleanFromInput('id');

        $output = new pnHTML();

        $output->SetInputMode(_PNH_VERBATIMINPUT);
        $output->Text(game_cheats_usermenu());
        $output->SetInputMode(_PNH_PARSEINPUT);

        if (!pnModAPILoad('Game_Cheats', 'user')) {
            $output->Text(_LOADFAILED);
            return $output->GetOutput();
        }

        // The API function is called.  The arguments to the function are passed in
        // as their own arguments array
        $cheat = pnModAPIFunc('Game_Cheats', 'user', 'get_cheat',
                               array('id' => $id));

        if ($cheat == false) {
            $output->Text(_GAMECHEATS_NOSUCHCHEAT);
            return $output->GetOutput();
        }

        $output->TableStart();

        // Game:
        $output->SetOutputMode(_PNH_RETURNOUTPUT);
        $row = array();
        $row[] = $output->Text(pnVarPrepForDisplay(_GAMECHEATS_GAME . ':'));
        $row[] = $output->Text(pnVarCensor($cheat['game']));
        $output->SetOutputMode(_PNH_KEEPOUTPUT);
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        $output->TableAddrow($row, 'left');
        $output->SetInputMode(_PNH_PARSEINPUT);

        // Platform:
        $output->SetOutputMode(_PNH_RETURNOUTPUT);
        $row   = array();
        $row[] = $output->Text(pnVarPrepForDisplay(_GAMECHEATS_PLATFORM . ':'));
        $row[] = $output->Text(pnVarCensor($cheat['platform']));
        $output->SetOutputMode(_PNH_KEEPOUTPUT);
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        $output->TableAddrow($row, 'left');
        $output->SetInputMode(_PNH_PARSEINPUT);

        // Cheat
        $output->SetOutputMode(_PNH_RETURNOUTPUT);
        $row   = array();
        $row[] = $output->Text(pnVarPrepForDisplay(_GAMECHEATS_CHEAT . ':'));
        $row[] = $output->Text(pnVarCensor($cheat['cheat']));
        $output->SetOutputMode(_PNH_KEEPOUTPUT);
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        $output->TableAddrow($row, 'left');
        $output->SetInputMode(_PNH_PARSEINPUT);

        // Where to put it:
        $output->SetOutputMode(_PNH_RETURNOUTPUT);
        $row   = array();
        $row[] = $output->Text(pnVarPrepForDisplay(_GAMECHEATS_CHEAT_WHERE
                               . ':'));
        $row[] = $output->Text(pnVarCensor($cheat['where']));
        $output->SetOutputMode(_PNH_KEEPOUTPUT);
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        $output->TableAddrow($row, 'left', 'top');
        $output->SetInputMode(_PNH_PARSEINPUT);

        // Results:
        $output->SetOutputMode(_PNH_RETURNOUTPUT);
        $row   = array();
        $row[] = $output->Text(pnVarPrepForDisplay(_GAMECHEATS_CHEAT_RESULTS
                               . ':'));
        $row[] = $output->Text(pnVarCensor($cheat['results']));
        $output->SetOutputMode(_PNH_KEEPOUTPUT);
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        $output->TableAddrow($row, 'left', 'top');
        $output->SetInputMode(_PNH_PARSEINPUT);

        $output->TableEnd();

        $output->SetInputMode(_PNH_VERBATIMINPUT);
        $output->Text(pnModCallHooks('item',
                                     'display',
                                     $id,
                                     pnModURL('Game_Cheats',
                                              'user',
                                              'display_cheat',
                                              array('id' => $id))));
        $output->SetInputMode(_PNH_PARSEINPUT);

        // Return the output that has been generated by this function
        return $output->GetOutput();
    }

    /**
     * generate menu fragment
     */

    function game_cheats_usermenu()
    {
        $output = new pnHTML();

        // Start options menu
        $output->Text(pnGetStatusMsg());
        $output->Linebreak(2);

      //  $output->TableStart(_GAMECHEATS_MENU);
        $output->TableStart();

        $output->SetInputMode(_PNH_VERBATIMINPUT);
        $output->Text('<center>' . alpha($output) . '</center>');
        $output->SetInputMode(_PNH_PARSEINPUT);

        $output->SetOutputMode(_PNH_RETURNOUTPUT);
        $columns = array();
        $columns[] = $output->URL(pnVarPrepForDisplay(pnModURL('Game_Cheats',
                                                               'user',
                                                               'view_cheats')),
                                  _GAMECHEATS_VIEWCHEATS);
        $output->SetOutputMode(_PNH_KEEPOUTPUT);
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        $output->TableAddRow($columns);
        $output->SetInputMode(_PNH_PARSEINPUT);

        // for the admins extended version:
        if (pnSecAuthAction(0, 'Game_Cheats::', '::', ACCESS_ADMIN)) {
            $columns = array();

            $output->SetOutputMode(_PNH_RETURNOUTPUT);
            $columns[] = $output->URL(pnVarPrepForDisplay(
                                      pnModURL('Game_Cheats',
                                               'admin',
                                               'platforms_edit')),
                                      _GAMECHEATS_PLATFORMSEDIT);
            $columns[] = $output->URL(pnVarPrepForDisplay(
                                      pnModURL('Game_Cheats',
                                               'admin',
                                               'new_cheat')),
                                      _GAMECHEATS_NEWCHEAT);
            $columns[] = $output->URL(pnVarPrepForDisplay(
                                      pnModURL('Game_Cheats',
                                               'user',
                                               'view_cheats',
                                               array( 'which' => 'all'))),
                                               _GAMECHEATS_VIEWCHEATS);
            $output->SetOutputMode(_PNH_KEEPOUTPUT);
            $output->SetInputMode(_PNH_VERBATIMINPUT);
            $output->TableAddRow($columns);
            $output->SetInputMode(_PNH_PARSEINPUT);
        }

        $output->TableEnd();

        $search = search_form();
        $output->SetInputMode(_PNH_VERBATIMINPUT);
        $output->Text($search);
        $output->SetInputMode(_PNH_PARSEINPUT);
        return $output->GetOutput();
    }

    function search_form() {

        $auth_id = pnSecGenAuthKey();
        return "
        <form method=\"POST\" action=\"modules.php\">
        <table border=\"0\" cellspacing=\"2\" width=\"100%\">
            <tr>
                <td valign=\"top\" align=center>
                <b>"
    ._GAMECHEATS_SEARCH_FOR_GAME.":</b>
                <input type=\"text\" name=\"game_search\" size=\"35\"><br>
                <input type=\"hidden\" name=\"authid\" value=\"$auth_id\">
                <br>  
                <input type=\"submit\" value=\""
    ._SUBMIT."\">
                </td>
            </tr>
        </table>
    </form>"
    ;

    }


    ?>
  • nvm we found it
  • Hey,

    I have a local gaming site here in Tucson, Az, and was wondering if you all would mind if I acquired a copy of that module. I have been looking for something like that for awhile now.

This list is based on users active over the last 60 minutes.