• 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!

AAC Hiding news tickers

SamX

VoltageOT Developer
Joined
Aug 27, 2010
Messages
557
Reaction score
151
Location
Canada
Hello,

I am using the changelog system for news tickers on my website. The issue I am having is the tickers show up on every page. I'd like them to only show on the front page (the news page).

Is there a way to make the function check if it's on the news page?

Here is changelogs from index.php
Code:
        if ($config['UseChangelogTicker']) {
            //////////////////////
            // Changelog ticker //
            // Load from cache
            $changelogCache = new Cache('engine/cache/changelog');
            $changelogs = $changelogCache->load();

            if (isset($changelogs) && !empty($changelogs) && $changelogs !== false) {
                ?>
                <table id="changelogTable">
                    <tr class="yellow">
                        <td colspan="2">Latest Changelog Updates (<a href="changelog.php">Click here to see full changelog</a>)</td>
                    </tr>
                    <?php
                    for ($i = 0; $i < count($changelogs) && $i < 5; $i++) {
                        ?>
                        <tr>
                            <td><?php echo getClock($changelogs[$i]['time'], true, true); ?></td>
                            <td><?php echo $changelogs[$i]['text']; ?></td>
                        </tr>
                        <?php
                    }
                    ?>
                </table>
                <?php
            } else echo "No changelogs submitted.";
        }
 
can you show us the full index?
index.php
Code:
<?php if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0") { require_once 'login.php'; die(); } // Client 11 loginWebService
require_once 'engine/init.php'; include 'layout/overall/header.php';

    if (!isset($_GET['page'])) {
        $page = 0;
    } else {
        $page = (int)$_GET['page'];
    }

    if ($config['allowSubPages'] && file_exists("layout/sub/index.php")) include 'layout/sub/index.php';
    else {
        if ($config['UseChangelogTicker']) {
            //////////////////////
            // Changelog ticker //
            // Load from cache
            $changelogCache = new Cache('engine/cache/changelog');
            $changelogs = $changelogCache->load();

            if (isset($changelogs) && !empty($changelogs) && $changelogs !== false) {
                ?>
                <table id="changelogTable">
                    <tr class="yellow">
                        <td colspan="2">Latest Changelog Updates (<a href="changelog.php">Click here to see full changelog</a>)</td>
                    </tr>
                    <?php
                    for ($i = 0; $i < count($changelogs) && $i < 5; $i++) {
                        ?>
                        <tr>
                            <td><?php echo getClock($changelogs[$i]['time'], true, true); ?></td>
                            <td><?php echo $changelogs[$i]['text']; ?></td>
                        </tr>
                        <?php
                    }
                    ?>
                </table>
                <?php
            } else echo "No changelogs submitted.";
        }
       
        $cache = new Cache('engine/cache/news');
        if ($cache->hasExpired()) {
            $news = fetchAllNews();
            $cache->setContent($news);
            $cache->save();
        } else {
            $news = $cache->load();
        }
       
        // Design and present the list
        if ($news) {
           
            $total_news = count($news);
            $row_news = $total_news / $config['news_per_page'];
            $page_amount = ceil($total_news / $config['news_per_page']);
            $current = $config['news_per_page'] * $page;

            function TransformToBBCode($string) {
                $tags = array(
                    '[center]{$1}[/center]' => '<center>$1</center>',
                    '[b]{$1}[/b]' => '<b>$1</b>',
                    '[size={$1}]{$2}[/size]' => '<font size="$1">$2</font>',
                    '[img]{$1}[/img]'    => '<a href="$1" target="_BLANK"><img src="$1" alt="image" style="width: 100%"></a>',
                    '[link]{$1}[/link]'    => '<a href="$1">$1</a>',
                    '[link={$1}]{$2}[/link]'   => '<a href="$1" target="_BLANK">$2</a>',
                    '[color={$1}]{$2}[/color]' => '<font color="$1">$2</font>',
                    '[*]{$1}[/*]' => '<li>$1</li>',
                    '[youtube]{$1}[/youtube]' => '<div class="youtube"><div class="aspectratio"><iframe src="//www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe></div></div>',
                );
                foreach ($tags as $tag => $value) {
                    $code = preg_replace('/placeholder([0-9]+)/', '(.*?)', preg_quote(preg_replace('/\{\$([0-9]+)\}/', 'placeholder$1', $tag), '/'));
                    $string = preg_replace('/'.$code.'/i', $value, $string);
                }
                return $string;
            }
            for ($i = $current; $i < $current + $config['news_per_page']; $i++) {
                if (isset($news[$i])) {
                    ?>
                    <table id="news">
                        <tr class="yellow">
                            <td class="zheadline"><?php echo getClock($news[$i]['date'], true) .' by <a href="characterprofile.php?name='. $news[$i]['name'] .'">'. $news[$i]['name'] .'</a> - <b>'. TransformToBBCode($news[$i]['title']) .'</b>'; ?></td>
                        </tr>
                        <tr>
                            <td>
                                <p><?php echo TransformToBBCode(nl2br($news[$i]['text'])); ?></p>
                            </td>
                        </tr>
                    </table>
                    <?php
                } 
            }


            echo '<select name="newspage" onchange="location = this.options[this.selectedIndex].value;">';

            for ($i = 0; $i < $page_amount; $i++) {

                if ($i == $page) {

                    echo '<option value="index.php?page='.$i.'" selected>Page '.$i.'</option>';

                } else {

                    echo '<option value="index.php?page='.$i.'">Page '.$i.'</option>';
                }
            }
           
            echo '</select>';

        } else {
            echo '<p>No news exist.</p>';
        }
    }
include 'layout/overall/footer.php'; ?>

layout/sub/index.php
Code:
<?php if($_SERVER['HTTP_USER_AGENT'] == "Mozilla/5.0") { require_once 'login.php'; die(); } // Client 11 loginWebService
require_once 'engine/init.php';
error_reporting(E_ALL ^ E_NOTICE);
    if (!isset($_GET['page'])) {
        $page = 0;
    } else {
        $page = (int)$_GET['page'];
    }
        $config['news_per_page'] = 1;
        $cache = new Cache('engine/cache/news');
        if ($cache->hasExpired()) {
            $news = fetchAllNews();
            $cache->setContent($news);
            $cache->save();
        } else {
            $news = $cache->load();
        }
       
        // Design and present the list
        if ($news) {
           
            $total_news = count($news);
            $row_news = $total_news / $config['news_per_page'];
            $page_amount = ceil($total_news / $config['news_per_page']);
            $current = $config['news_per_page'] * $page;

            function TransformToBBCode($string) {
                $tags = array(
                    '[center]{$1}[/center]' => '<center>$1</center>',
                    '[b]{$1}[/b]' => '<b>$1</b>',
                    '[size={$1}]{$2}[/size]' => '<font size="$1">$2</font>',
                    '[img]{$1}[/img]'    => '<a href="$1" target="_BLANK"><img src="$1" alt="image" style="width: 100%"></a>',
                    '[link]{$1}[/link]'    => '<a href="$1">$1</a>',
                    '[link={$1}]{$2}[/link]'   => '<a href="$1" target="_BLANK">$2</a>',
                    '[color={$1}]{$2}[/color]' => '<font color="$1">$2</font>',
                    '[*]{$1}[/*]' => '<li>$1</li>',
                    '[youtube]{$1}[/youtube]' => '<div class="youtube"><div class="aspectratio"><iframe src="//www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe></div></div>',
                );
                foreach ($tags as $tag => $value) {
                    $code = preg_replace('/placeholder([0-9]+)/', '(.*?)', preg_quote(preg_replace('/\{\$([0-9]+)\}/', 'placeholder$1', $tag), '/'));
                    $string = preg_replace('/'.$code.'/i', $value, $string);
                }
                return $string;
            }
            echo '
            <style>
            .NewsHeadlineBackground
            {
                position: relative;
                height: 28px;
                margin-bottom: 5px;
                background-repeat: repeat-x;
                border-left: 1px solid #000000;
                border-right: 1px solid #000000;
                font-size: 10pt;
                color: white;
                line-height: 28px;
            }
            </style>
            ';
           
           
            for ($i = $current; $i < $current + $config['news_per_page']; $i++) {
                if (isset($news[$i])) {
                    ?>
                    <div class="news-content-container">
                    <h2 class="news-title"><?php echo TransformToBBCode($news[$i]['title']); ?></h2>
                    <span class="news-date">posted on <?php echo date('d M Y' ,$news[$i]['date']); ?></span>
                    <br>   
                        <div class="bg-top"></div>
                            <div class="bg-mid">
                                    <?php echo TransformToBBCode(nl2br($news[$i]['text'])); ?>
                                   
                                    <div style="clear:both;"></div>
                            </div>
                        <div class="bg-bot"></div>
                    </div>
                    <?php
                } 
            }

            ?>
           
            <?php

$p = $_GET['page'];
if(!isset($p))
    $p = 0;
?>                       
                        <div class="news-content-container">
                        <?php 
                       
                        if($p > 0){
                            $fix = 'left';
                        ?>
                                <a style="float: left;" class="prev" href="index.php?page=<?php echo $p - 1 ?>"></a>
                        <?php 

                        }
                       
                        ?>
                       
                        <?php 
                       
                        if($p < $page_amount - 1){
                            $fix = 'right';
                        ?>
                        <a style="float: right;" class="next" href="index.php?page=<?php echo $p + 1 ; ?>"></a>
                        <?php 
                       
                        }
                       
                        ?><div style="line-height: 40px;width: 620px;float: <?php echo $fix; ?>;;text-align:center;">Page  <?php echo $p; ?> of <?php echo $page_amount-1; ?></div>
                        <div style="clear: both;"></div>
                        </div>
               
<?php


        } else {
            echo '<p>No news exist.</p>';
        }

?>
 
its really weird, can you show some pics?
Here is the main page/news page:
FdpYpcH.png


Here is the guilds page, as you can see the news ticker is still there.
8ETrYVC.png
 
actually thats a different file, maybe header.php but not index
Here's header.php
Code:
<!DOCTYPE html>
    <head>
        <meta charset="UTF-8">
        <title><?php echo $config['site_title']; ?></title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link href="https://fonts.googleapis.com/css?family=Audiowide" rel="stylesheet">
                <script src="layout/jquery-3.1.1.min.js"></script>
        <script src="layout/jquery.slides.min.js"></script>
        <link rel="stylesheet" type="text/css" href="layout/style.css">
        <link rel="stylesheet" type="text/css" href="layout/jquery-slides.css">
            <style>
                .display-none {
                    display: none !important;
                }

                .display-inline {
                    display: inline !important;
                }
            </style>
            <script>
                jQuery(function(){
                    jQuery('.changelog_trigger').click(function(e){
                        e.preventDefault();
                    jQuery('.hide'+$(this).attr('targetid')).toggle();
                    jQuery('.expand'+$(this).attr('targetid')).toggle();     
                   
                            jQuery('.changelog_big'+$(this).attr('targetid')).toggleClass("display-inline");
                         
                         jQuery('.changelog_small'+$(this).attr('targetid')).toggleClass("display-none");
                       
                    });
                });
            </script>
            <script>

              $(function() {
              $('#slides').slidesjs({
                    width: 561,
                    height: 308,
                    play: {
                    active: false,
                    auto: true,
                    interval: 5000,
                    swap: false,
                    pauseOnHover: false,
                    restartDelay: 2500
                },
                pagination: {
                    active: false,
                }
              });
              });
         </script>
    </head>
    <body>
        <div class="page">
            <div class="top-cnt">
                <div class="frame"></div>
                <div class="slider">
                    <div class="sbox">
                        <div id="slides">
                            <div class="slide">
                                <span class="desc">Participate in challenging quests!</span>
                                <img src="layout/img/slidenumberone.png">
                            </div>
                            <div class="slide">
                                <span class="desc">Text2</span>
                                <img src="layout/img/slide1.png">
                            </div>
                            <div class="slide">
                                <span class="desc">Text3</span>
                                <img src="layout/img/slide1.png">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="mid-section">
                    <a class="download-btn" href="YOUR DOWNLOAD LINK HERE"></a>
                    <!-- <div class="players-online">280 PLAYERS ONLINE</div> -->
                                <?php
                                $status = true;
                               
                                    @$sock = fsockopen ($config['status']['status_ip'], $config['status']['status_port'], $errno, $errstr, 1);
                                    if(!$sock) {
                                        echo '<div class="players-offline">Server Offline</div>';
                                        $status = false;
                                    }
                                    else {
                                        $info = chr(6).chr(0).chr(255).chr(255).'info';
                                        fwrite($sock, $info);
                                        $data='';
                                        while (!feof($sock))$data .= fgets($sock, 1024);
                                        fclose($sock);
                                        echo '<div class="players-online">'.user_count_online().' PLAYERS ONLINE</DIV>';
                                       
                                    }
                               
                               
                                    ?>
                </div>
                <div class="login-box">
                    <center>
                                <?php if (user_logged_in() === false) { ?>
                                <div class="login"></div>
                                        <form action="login.php" method="post" style="margin-bottom: 0;">
                                       
                                            <img style="margin-top: 3px;" src="layout/img/account-name.png"/>
                                            <input class="login-input" type="text" name="username" placeholder="********">
                                           
                                            <img src="layout/img/password.png"/>
                                            <input class="login-input" type="password" name="password" placeholder="********">
                                           
                                            <input type="submit" name="Submit" value="" class="login-submit">
                                            <a href="register.php" class="register-btn"></a>
                                            <?php
                                                /* Form file */
                                                Token::create();
                                            ?>
                                        </form>
                                <?php }else{ ?>
                                <div class="acc_menu">
                                    <center><br>
                                        Welcome, <?php echo $user_data['name']; ?><br>
                                                <a href='myaccount.php' class="myacc-btn">Manage Account</a>
                                                <a href='createcharacter.php' class="myacc-btn">Create Character</a>
                                                <a href='changepassword.php' class="myacc-btn">Change Password</a>
                                                <a href='settings.php' class="myacc-btn">Settings</a>
                                                <a href='logout.php' class="myacc-btn">Logout</a>
                                               
                                               

                                    </center>
                                </div>
                                <?php } ?>
                    </center>
                </div>
            </div>
            <div class="left-cnt">
                <div class="bg-top"></div>
                <div class="bg-mid">
                    <div class="content">   
                                                <center>
                                                <?php if (user_logged_in() === true) { if (is_admin($user_data)){ ?>
                                                <font color="red">ADMIN PANEL</font><br>
                                                    <a href='admin.php'>Admin Page</a><br>
                                                    <a href='admin_news.php'>Admin News</a><br>
                                                    <a href='admin_gallery.php'>Admin Gallery</a><br>
                                                    <a href='admin_skills.php'>Admin Skills</a><br>
                                                    <a href='admin_reports.php'>Admin Reports</a><br>
                                                    <a href='admin_helpdesk.php'>Admin Helpdesk</a><br>
                                                    <a href='admin_shop.php'>Admin Shop</a><br><br>
                                                <?php } } ?>
                                                </center>
                        <a class="big-btn"href="index.php">News</a>
                        <a class="big-btn"href="serverinfo.php">About VoltageOT</a>
                        <a class="big-btn"href="sub.php?page=characters">Characters</a>
                        <a class="big-btn"href="guilds.php">Guilds</a>
                        <a class="big-btn"href="highscores.php">Highscores</a>
                        <a class="big-btn"href="rules.php">Rules</a>
                        <a class="big-btn"href="forum.php">Forum</a>
                        <a class="big-btn blue"href="buypoints.php">Donate</a>
                        <a class="big-btn blue"href="shop.php">Shop</a>
                    </div>
                </div>
                <div class="bg-bot"></div>
            </div>
            <div class="right-cnt">
                <!-- CHANGELOG SYSTEM -->
                <div class="bg-top"></div>
                <div class="bg-mid">
                    <div class="changelog-container">
                        <div class="content">
                        <?php
                        //////////////////////
                        // Changelog ticker //
                        // Load from cache
                        $changelogCache = new Cache('engine/cache/changelognews');
                        $changelogs = $changelogCache->load();

                        if (isset($changelogs) && !empty($changelogs) && $changelogs !== false) {
                            ?>
                                <?php
                                for ($i = 0; $i < count($changelogs) && $i < 5; $i++) { $islong = 0;
                                    ?>
                                   
                                <div class="bg-top"></div>
                                <div class="bg-mid">
                                    <div class="left-text-cnt">
                                        <p><span style="color: #b781c3;"><?php echo date('d/m/Y', $changelogs[$i]['time']); ?></span> 
                                            <span class="changelog_small<?php echo $i; ?>"  style="display: inline;"><?php if(strlen($changelogs[$i]['text']) > 47) { $islong = 1; echo substr($changelogs[$i]['text'], 0, 50) . '...';}else { echo $changelogs[$i]['text'];} ?></span>
                                            <span class="changelog_big<?php echo $i; ?>"  style="display: none;"><?php echo $changelogs[$i]['text']; ?></span>
                                        </p>
                                    </div>
                                    <div class="right-btn-cnt">
                                    <?php if($islong == 1){?>
                                        <a class="expand expand<?php echo $i; ?> changelog_trigger" targetid="<?php echo $i; ?>" href="#"></a>
                                        <a class="hide hide<?php echo $i; ?> changelog_trigger" style="display:none;" targetid="<?php echo $i; ?>" href="#"></a>
                                    <?php } ?>
                                    </div>
                                    <div style="clear: both;"></div>
                                </div>
                                <div class="bg-bot"></div>
                                    <?php
                                }
                                ?>
                            <?php
                        } else echo "<center>No changelogs submitted.</center>";
                       
                        ?>
                        </div>
                    </div>

                </div>
                <div class="bg-bot"></div>
                <br>
                <div class="bg-top"></div>
                <div class="bg-mid">
                    <div class="news-content-container">/code]
 
so i cant help you cus its a css problem, maybe my edit but cant figure out only with pictures, i got my own xampp server running and I can test but you will have to send me your layout and (ofc) you wont believe me (I guess) and thats ok :)
but with that information I gave to you you will be able to notice whats the problem, anyways you can still send me a pm if you want to.
edit@ I got my very own website if you want to check it out
 
Back
Top