简体   繁体   English

以HTML显示的PHP代码

[英]PHP code showing in HTML

There's probably an obvious answer to this but I'm new to the world of PHP.. 可能有一个明显的答案,但是我是PHP世界的新手。

So I have $dbpages = fetchAllPagesD($path."/"); 所以我有$dbpages = fetchAllPagesD($path."/"); in my PHP code for UserCake and it's showing the concerned path on the page, before any of the content. 在我的UserCake的PHP代码中,它在页面上的任何内容之前都显示了相关路径。

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>

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. 如果无法访问整个代码(包括所有功能和包含的内容),我们将无法找到它,但是对于此问题,确实没有必要,您只需要学习调试代码即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM