List

Try: ca/tecreations/ViewFile.php -- Online


<?php
    require_once $_SERVER['DOCUMENT_ROOT'] . "/tec_SiteRoot.php";

    global $text, $error_msg, $path;

    if (isset($_REQUEST['path']) && !empty($_REQUEST['path'])) {
        $path = $_REQUEST['path'];
        if (!empty($path)) {
            if (startsWith($path,"/")) {
                $error_msg = "Absolute path found. Loading as relative.";
                $path = substr($path,1);
                $text = htmlentities(getFileText("/var/www/tecreations.ca/html/" . $path),ENT_QUOTES|ENT_HTML401);
            } else if (strpos($path,"..") !== false ) {
                $error_msg = "Cannot go to higher level directory. Sorry, privacy and security. Specify a subpath and filename.";
            } else {
                $text = htmlentities(getFileText("/var/www/tecreations.ca/html/" . $path),ENT_QUOTES|ENT_HTML401);
            }
        }
    }
    require_once $DOCROOT . $TEC_PREFIX_DIR . "html_start.php";
?>
</head>
<body>
<?php 
    include_once $DOCROOT . $TEC_PREFIX_DIR . "html_brand_menu_start.php";
    include_once $DOCROOT . $TEC_PREFIX_DIR . "menu/menuRoot.php";
    include_once $DOCROOT . $TEC_PREFIX_DIR . "html_brand_menu_stop.php";

    GLOBAL $error_msg;
    if (!empty($error_msg)) {
        print("<p>&nbsp;</p>");
        print("<p><span class='red'>$error_msg</span></p>\n");
        print("<p>&nbsp;</p>");
    }
?>
<p><a href="/ca/tecreations/List.php">List</a></p>
<p>Try: ca/tecreations/ViewFile.php -- <a href="/<?php global $path; echo $path; ?>">Online</a></p>
<div class="padded jumbotron">
    <form name="" id="" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="GET">
        <label for="path">Enter a path WITHOUT a preceding slash:</label>
        <input type="text" name="path" id="path" placeholder="<?php 
                                                                  global $path;
                                                                  if (empty($path)) {
                                                                      print("Path to file on https://tecreations.ca/");
                                                                  } else {
                                                                      print($path);
                                                                  }
                                                              ?>" 
                                                        class="form-control">

<!--                                                 onfocus="document.getElementById('path').value='';" ==-->
        <input type="submit" value="View File">
    </form>
</div>
<pre>
<code class="blueAndGrey">
<?php

    GLOBAL $text;
    print($text);
?>
</code>
</pre>
</body>
</html>