• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved [PHP] [HELP] Blank page houses and highscore ZnoteAcc

therrax

Member
Joined
Jul 12, 2012
Messages
262
Solutions
1
Reaction score
11
Hi Everyone!
TFS 0.4
I changed Znote default layout to: http://otland.net/threads/znote-aac-dwarf-layout.208644/
and my highscores and houses doesn't work.. I have blank pages... Help me please.. :(
My highscores.php
Code:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php';
if ($config['log_ip']) {
    znote_visitor_insert_detailed_data(3);
}
if (empty($_POST) === false) {
  
    #if ($_POST['token'] == $_SESSION['token']) {
  
    /* Token used for cross site scripting security */
    if (isset($_POST['token']) && Token::isValid($_POST['token'])) {
      
        $skillid = (int)$_POST['selected'];
        $cache = new Cache('engine/cache/highscores');

        if ($cache->hasExpired()) {
            $tmp = highscore_getAll();

            $cache->setContent($tmp);
            $cache->save();

            $array = isset($tmp[$skillid]) ? $tmp[$skillid] : $tmp[7];
        } else {
            $tmp = $cache->load();
            $array = $tmp[$skillid];
        }
      
        if ($skillid < 9) {
        // Design and present the list
        if ($array) {
            ?>
            <h2>
                <?php echo ucfirst(skillid_to_name($skillid)); ?> scoreboard. Next update:
                    <?php
                        if ($cache->remainingTime() > 0) {
                            $hours = seconds_to_hours($cache->remainingTime());
                            $minutes = ($hours - (int)$hours) * 60;
                            $seconds = ($minutes - (int)$minutes) * 60;
                            if ($hours >= 1) {
                                echo (int)$hours .'h';
                            }
                            if ($minutes >= 1) {
                                echo ' '. (int)$minutes .'m';
                            }
                            if ($seconds >= 1) {
                                echo ' '. (int)$seconds .'s';
                            }
                        } else {
                            echo '0s';
                        }
                      
                    ?>. <?php echo remaining_seconds_to_clock($cache->remainingTime());?>
            </h2>
            <table id="highscoresTable">
                <tr class="yellow">
                    <td>Name:</td>
                    <?php
                    if ($skillid == 7) echo '<td>Level:</td><td>Experience:</td>';
                    else {
                    ?>
                    <td>Value:</td>
                    <?php
                    }
                    if ($skillid == 7 || $skillid == 6 || $skillid == 5) {
                        echo '<td>Vocation:</td>';
                    }
                    ?>
                </tr>
                    <?php
                    foreach ($array as $value) {
                        // start foreach
                        if ($value['group_id'] < 2) {
                            echo '<tr>';
                            echo '<td><a href="characterprofile.php?name='. $value['name'] .'">'. $value['name'] .'</a></td>';
                            if ($skillid == 7) echo '<td>'. $value['level'] .'</td>';
                            echo '<td>'. $value['value'] .'</td>';
                            if ($skillid == 7 || $skillid == 6 || $skillid == 5) {
                                echo '<td>'. $value['vocation'] .'</td>';
                            }
                            echo '</tr>';
                        }
                        // end foreach
                    }
                    ?>
            </table>
            <?php
        } else {
            echo 'Empty list, it appears all players have less than 500 experience points.';
        }
        //Done.
        }
    } else {
        echo 'Token appears to be incorrect.<br><br>';
        //Token::debug($_POST['token']);
        echo 'Please clear your web cache/cookies <b>OR</b> use another web browser<br>';
    }
}

/*
0 fist: SELECT (SELECT `name` from `players` WHERE `player_id`=`id`) AS `name`, `value` FROM `player_skills` WHERE `skillid`=0
1 club:
2 sword:
3 axe:
4 dist:
5 Shield:
6 Fish
7 Hardcoded experience
8 Hardcoded maglevel
*/
include 'layout/overall/footer.php'; ?>
 
Last edited:
and houses.php
Code:
<?php require_once 'engine/init.php'; include 'layout/overall/header.php';
if ($config['log_ip']) {
    znote_visitor_insert_detailed_data(3);
}
if (empty($_POST) === false && $config['TFSVersion'] === 'TFS_03') {
   
    #if ($_POST['token'] == $_SESSION['token']) {
   
    /* Token used for cross site scripting security */
    if (isset($_POST['token']) && Token::isValid($_POST['token'])) {
       
        $townid = (int)$_POST['selected'];
        $cache = new Cache('engine/cache/houses');
        $array = array();
        if ($cache->hasExpired()) {
            $tmp = fetchAllHouses_03();
            $cache->setContent($tmp);
            $cache->save();
           
            foreach ($tmp as $t) {
                if ($t['town'] == $townid) $array[] = $t;
            }
            $array = isset($array) ? $array : false;
        } else {
            $tmp = $cache->load();
            foreach ($tmp as $t) {
                if ($t['town'] == $townid) $array[] = $t;
            }
            $array = isset($array) ? $array : false;
        }
       
        // Design and present the list
        if ($array) {
            ?>
            <h2>
                <?php echo ucfirst(town_id_to_name($townid)); ?> house list.
            </h2>
            <table id="housesTable">
                <tr class="yellow">
                    <td>Name:</td>
                    <td>Size:</td>
                    <td>Doors:</td>
                    <td>Beds:</td>
                    <td>Price:</td>
                    <td>Owner:</td>
                   
                </tr>
                    <?php
                    foreach ($array as $value) {
                        // start foreach
                        echo '<tr>';
                        echo "<td>". $value['name'] ."</td>";
                        echo "<td>". $value['size'] ."</td>";
                        echo "<td>". $value['doors'] ."</td>";
                        echo "<td>". $value['beds'] ."</td>";
                        echo "<td>". $value['price'] ."</td>";
                        if ($value['owner'] == 0) echo "<td>None</td>";
                        else {
                            $data = user_character_data($value['owner'], 'name');
                            echo '<td><a href="characterprofile.php?name='. $data['name'] .'">'. $data['name'] .'</a></td>';
                        }
                        echo '</tr>';
                        // end foreach
                    }
                    ?>
            </table>
            <?php
        } else {
            echo 'Empty list, it appears no houses are listed in this town.';
        }
        //Done.
    } else {
        echo 'Token appears to be incorrect.<br><br>';
        //Token::debug($_POST['token']);
        echo 'Please clear your web cache/cookies <b>OR</b> use another web browser<br>';
    }
} else {
    if (empty($_POST) === true && $config['TFSVersion'] === 'TFS_03') {
        if ($config['allowSubPages']) header('Location: sub.php?page=houses');
        else echo 'Sub page system disabled.';
    } else {
        $house = $config['house'];
        if (!is_file($house['house_file'])) {
            echo("<h3>House file not found</h3><p>FAILED TO LOCATE/READ FILE AT:<br><font color='red'>". $house['house_file'] ."</font><br><br>LINUX users: Make sure www-data have read access to file.<br>WINDOWS users: Learn to write correct file path.</p>");
            exit();
        }

        // Load and cache SQL house data:
        $cache = new Cache('engine/cache/houses/sqldata');
        if ($cache->hasExpired()) {
            $house_query = mysql_select_multi('SELECT `players`.`name`, `houses`.`id` FROM `players`, `houses` WHERE `houses`.`owner` = `players`.`id`;');
           
            $cache->setContent($house_query);
            $cache->save();
        } else {
            $house_query = $cache->load();
        }

        $sqmPrice = $house['price_sqm'];
        $house_load = simplexml_load_file($house['house_file']);
        if ($house_query !== false && $house_load !== false) {
            ?>
            <h2>House list</h2>
            <table>
                <tr class="yellow">
                    <td><b>House</b></td>
                    <td><b>Location</b></td>
                    <td><b>Owner</b></td>
                    <td><b>Size</b></td><td><b>Rent</b></td>
                </tr>

                <?php
                //execute code.
                foreach($house_query as $row) {
                    $house_info[(int)$row['id']] = '<a href="characterprofile.php?name='. $row['name'] .'">'. $row['name'] .'</a>';
                }
                foreach ($house_load as $house_fetch){
                    $house_price = (int)$house_fetch['size'] * $sqmPrice;
                    ?>
                    <tr>
                        <td><?php echo htmlspecialchars($house_fetch['name']); ?></td>
                        <td>
                            <?php
                            if (isset($config['towns'][(int)$house_fetch['townid']])) echo htmlspecialchars($config['towns'][(int)$house_fetch['townid']]);
                            else echo '(Missing town)';
                            ?>
                        </td>
                        <td>
                            <?php
                            if (isset($house_info[(int)$house_fetch['houseid']])) echo $house_info[(int)$house_fetch['houseid']];
                            else echo 'None [Available]';
                            ?>
                        </td>
                        <td><?php echo $house_fetch['size']; ?></td>
                        <td><?php echo $house_price; ?></td>
                    </tr>
                    <?php
                }
                ?>
            </table>
            <?php
        } else echo '<p><font color="red">Something is wrong with the cache.</font></p>';
    }
}
include 'layout/overall/footer.php'; ?>
 
Back
Top