0

There's probably an obvious answer to this but I'm new to the world of PHP..

So I have $dbpages = fetchAllPagesD($path."/"); in my PHP code for UserCake and it's showing the concerned path on the page, before any of the content.

I don't want it to show anything at all.. Any ideas?

I hate dropping all my code in like this but it will help in finding an answer:

<?php
/*
UserCake Version: 2.0.2
http://usercake.com
*/
$root=str_replace('\\','/',$_SERVER['DOCUMENT_ROOT']);
require_once("models/config.php");
if (!securePage($_SERVER['PHP_SELF'])){die();}
$path="";
if(isset($_GET['path'])) $path=$_GET['path'];

$script=dirname($_SERVER['PHP_SELF']);
$baspth=$path;
$dir = glob($root.$path."/*" ,GLOB_ONLYDIR);


$pages = getPageFiles($root.$path); //Retrieve list of pages in root usercake folder
$dbpages = fetchAllPages(); //Retrieve list of pages in pages table
$creations = array();
$deletions = array();

//Check if any pages exist which are not in DB
if (count($pages) > 0)
foreach ($pages as $page){
    if(!isset($dbpages[$page])){
        $creations[] = $page;   
    }
}

//Enter new pages in DB if found
if (count($creations) > 0) {
    createPages($creations) ;
}

if (count($dbpages) > 0){
    //Check if DB contains pages that don't exist
    foreach ($dbpages as $page){
        if(!isset($pages[$page['page']])){
            $deletions[] = $page['id']; 
        }
    }
}

//Delete pages from DB if not found
if (count($deletions) > 0) {
    deletePages($deletions);
}

//Update DB pages
$dbpages = fetchAllPagesD($path."/");

?>







<!DOCTYPE html>
<head>
    <!-- Page data -->
    <title>ClarkeWing.com - My ClarkeWing.com ID - Administration</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=1020">
    <meta name="robots" content="noindex">
    <meta name="author" content="Hugo Clarke-Wing">

    <!-- Mapping -->
    <link rel="home" href="http://www.clarkewing.com/">
    <link rel="index" href="http://www.clarkewing.com/sitemap/">

    <!-- CSS links -->
    <link type="text/css" rel="stylesheet" href="/media/global/light_template/light_template.css" />
    <link type="text/css" rel="stylesheet" href="/media/global/nav/navigation.css" />
    <link type="text/css" rel="stylesheet" href="/media/global/footer/footer.css" />
    <link type="text/css" rel="stylesheet" href="/secure/models/css/admin_pages.css" />
    <link type="text/css" rel="stylesheet" href="/secure/models/css/secure-header.css" />
    <link type="text/css" rel="stylesheet" href="/media/global/fonts/MyriadPro-Regular.css" />

    <!-- JS links -->
    <script type="text/javascript" src="/media/global/jquery.js"></script>
    <script type="text/javascript" src="/media/global/placeholderfix.js"></script>

    <!-- Analytics link -->
    <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    ga('create', '***********', 'clarkewing.com');
    ga('send', 'pageview');
    </script>
</head>


<body>

    <!-- HEADER -->
    <nav id="globalheader" class="secure">
<?php
$path_nav = $_SERVER['DOCUMENT_ROOT'];
$path_nav .= "/media/global/nav/navigation.php";
include($path_nav);
?>
    </nav>
    <!-- /HEADER -->


    <!-- - - - - - - - - - - - - - - - - - - - - - - CONTENT - - - - - - - - - - - - - - - - - - - - - - - -->
    <div id="main-wrapper">
        <div id="secure-header" class="admin">
<?php
include("secure-header.php");
?>
        </div>

        <div class="content">
            <div id="results">
            <?php echo resultBlock($errors,$successes); ?>
            </div>

            <div id="directories">
                <h2>Directories</h2>
                <?php
                //echo"<br>realpth:".$realpth." baspth:".$baspth." dirname (baspth):".dirname($baspth)."<br>";
                ?>
                <ul>
                    <?php
                    if($path!="/" )
                    {
                        $top=dirname($baspth);
                        if($top=="\\")$top="";
                        echo "<li><a href='".$_SERVER['PHP_SELF']."?path=".$top."'>../</a></li>";
                    }
                    if (count($dir) > 0)
                    foreach ($dir as $directory){
                    $directory =str_replace($root,'',$directory);
                        echo "<li><a href='".$_SERVER['PHP_SELF']."?path=".$directory."'>".basename($directory)."</a></li>";
                    }
                    ?>
                </ul>
            </div>

            <div id="pages">
                <?php
                echo "
                <h2>Current Directory: ".$baspth."/</h2>";
                ?>
                <table>
                    <thead>
                        <tr>
                            <th>ID</th>
                            <th>Page</th>
                            <th>Access</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        //Display list of pages
                        if (count($dbpages) > 0)
                        foreach ($dbpages as $page){
                            echo "
                            <tr>
                            <td>
                            ".$page['id']."
                            </td>
                            <td>
                            <a href ='admin_page.php?id=".$page['id']."'>".basename($page['page'])."</a>
                            </td>
                            <td>";
                            //Show public/private setting of page
                            if($page['private'] == 0){
                                echo "Public";
                            }
                            else {
                                echo "Private"; 
                            }
                            echo "
                            </td>
                            </tr>";
                        }
                        else echo "
                            <tr>
                                <td>&nbsp;</td>
                                <td>No PHP pages in this directory</td>
                                <td></td>
                            </tr>";
                        ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <!-- - - - - - - - - - - - - - - - - - - - - - - /CONTENT - - - - - - - - - - - - - - - - - - - - - - - -->


    <!-- FOOTER -->
<?php
$path_footer = $_SERVER['DOCUMENT_ROOT'];
$path_footer .= "/media/global/footer/footer.php";
include($path_footer);
?>
    <!-- /FOOTER -->

</body>
</html>
1
  • Do you mean that when you view your page in the web browser you're seeing the PHP code itself and not the result of the PHP code? If that's the case then your web server isn't interpreting PHP code. This would mean that PHP isn't properly installed on the server of isn't properly configured in some way. Commented Jul 16, 2013 at 15:50

1 Answer 1

1

Your path could be printed anywhere, from a function call, from an include etc.

You need to debug your own code and find where it is printed, delete parts of your code and reload your page, until it doesn't display anymore, then you will know which code prints it.

We can't find it without having access to your entire code, including all your functions and includes, but for this issue it's really not necessary, you just need to learn to debug your code.

Sign up to request clarification or add additional context in comments.

2 Comments

The line itself isn't displayed, but simply the path.. I added my full page code to the question, if that can help...
There is a lot of stuff that could print something. It could be a function, it could be an include. We can't find it for you, debug your code until you find where it prints the line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.