简体   繁体   中英

display html files based on the filename by searching it from the server

this is little complicated for me: say my server has 1200 files for example:

file:///D:/xampp/htdocs/bibek/address/WRTRThu-05-Jul-2012-14-02-14pm.html
file:///D:/xampp/htdocs/bibek/address/WRTRThu-05-Jul-2012-13-02-23pm.html
file:///D:/xampp/htdocs/bibek/address/BRTRThu-05-Jul-2012-13-05-35pm.html
file:///D:/xampp/htdocs/bibek/address/BRTRThu-05-Jul-2012-12-06-52pm.html etc.

as one can see each of them has a name: WRTR and BRTR and a day date and time. i have to write a script with php mysql javascript(only the last the last resort), to let a user to enter the date time day and the name (wrtr or brtr) and he will be able to view the corresponding files. can anyone suggest how to proceed?

according to sugesstion and with the help of maxhud, i got this, hats off to you...

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
    function showFile(){
        var name = document.getElementById("name").value;
        var dday = document.getElementById("dday").value;
        var month = document.getElementById("month").value;
        var year = document.getElementById("year").value;
        var hour =document.getElementById("hour").value;
        var minute = document.getElementById("minute").value;
        var second = document.getElementById("second").value;
        var ofday = document.getElementById("ofday").value;
        var day = document.getElementById("day").value;
        var ofday=document.getElementById("ofday").value;
        window.location = "address/" + name + day + "-" + dday+ "-" + month + "-" + year + "-" +hour + "-" + minute + "-" + second + ofday + ".html";
    }
</script>
</head>
<body>

    Name: <input id="name" placeholder="accountname"/><br/>

    Date: <input id="dday" placeholder="01-31"/> - <input id="month" placeholder="month"/> - <input id="year" placeholder="year"/><br/><br/>


    Time: <input id="hour" placeholder="24hours"/> - <input id="minute" placeholder="minute"> - <input id="second" placeholder="second"/>
     of Day <input id="ofday" placeholder="am/pm"/>
     <br/><br/>
     Day: <input id="day"/>
     <br/><br/>

    <button onclick="showFile()">Take me to the file</button>
</body>
</html>

and the php script: fileLocator2.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

    <title>Ethernet database check</title>
<style type="text/css">
body
{
    width:90%;
    max-height:auto;
    min-height:600px;
    background-color:#000;
    color:white;
    font-size:17px;
}
br{
    margin-bottom:1em;
}
#textleft
{
    float:left;
    text-align:left;
}
#textright
{
    float:right;
    margin-right:2em;
}
.inputcont{
    float:left;
    width:20%;
    margin-left:0.1em;
    autofocus:autofocus;
}
a:link
{
    text-decoration:none;
    color:white;
}
title
{

    border-radius:5px;
    font-size:3em;
    background-color:blue;
    color:white;
}

    .yellobutton
{
    background-color:yellow;
    margin-top:1%;
    float:right;
    margin-right:2%;
    width:10em;
    height:2.4em;
    border:1px solid blue;
    border:inset 1px solid black;
    box-shadow:2px 2px 5px #fff;
    color:black;
    font-weight:bold;
}

</style>
</head>
<body>
        <header style="height:4em;font-size:2em;"> Employee Access Only</header>
        <div style="margin:2em;padding:1em 1em 4em 1em;height:auto;border:1px solid #000;border-radius:5px;-moz-box-shadow:0 0 5px 2px #ddb;box-shadow:0 0 5px 2px #ddd;">
                <form method="POST" action="confirm.php">

            <div id="textleft">Path or folder:<br></div>
            <div id="textright"> <input id="path" name="path" placeholder="address no/"/>[?]</div><br/>

            <div id="textleft">Name of file:<br/></div>
            <div id="textright"> <input id="name" name="name" placeholder="filename"/><a href="#" title="WRTR &#13;BRTR">[?]</a></div><br/>

            <div id="textleft">Day:<br/></div>
            <div id="textright"> <input  id="day" name="day"/><a href="#" title="Mon Tue Wed Thu Fri Sat">[?]</a></div>
            <br/>
            <div id="textleft">Date:</div>
            <div id="textright"><input  id="ddate" placeholder="01-31" name="ddate"/> - <input id="month" placeholder="month" name="month"/> - <input id="year" placeholder="2001-2011" name="year"/><a href="#" title="date:01-02-03..31 &#13;month:Jan,Feb,Mar,Apr,May,Jun,Jul,Aug&#13; year:2001...2011">[?]</a></div><br/>
            <div id="textleft">Time:<br/></div>
            <div id="textright"><input  id="time" name="time"/><a href="#" title="hours-mins-seconds &#13; 13-20-23">[?]</a></div></br>

        <input type="submit" class="yellobutton" id="submit" name="submit" value="show me"/>
    </form>
    </div>
    <footer style="font-size:1.4em ;margin-top:20%;">&copy;Bibek Agarwal Scripts</footer>

</body>
</html>

and confirm.php

<?php
if(isset($_POST['submit']))
    {

    $pathfolder=trim($_POST['path']);
    $filename=trim($_POST['name']);
    $day=trim($_POST['day']);
    $ddate=trim($_POST['ddate']);
    $dmonth=trim($_POST['month']);
    $dyear=trim($_POST['year']);
    $time=trim($_POST['time']);
    /*echo 'path '.$pathfolder.'<br/>';
    echo 'filename '.$filename. '<br/>';
    echo 'day' . $day.'<br/>';
    echo 'time ' .$time. '<br/>';*/
     if((!empty($pathfolder)) && (!empty($filename)) && (!empty($day)) && (!empty($ddate)) && (!empty($dmonth)) && (!empty($dyear)) && (!empty($time)))
        {
            list($hour,$minute,$second)=explode("-",$time);


            echo 'hours '.$hour.'<br/>';
            echo 'minutes '.$minute.'<br/>';
            echo 'seconds '.$second.'<br/>';
            if(($hour>=12) && ($hour<=59))

                $flag="pm";

            if(($hour>=00) && ($hour<=11))
                  $flag="am";

                        $filesever=$pathfolder."/".$filename.$day."-".$ddate."-".$dmonth."-".$dyear."-".$hour."-".$minute."-".$second.$flag.".html";
                         header("Location:$filesever") ;
        }
        else 'Empty Inputs';

 }

?>      
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
    function showFile(){
        var name = document.getElementById("name").value;
        var time = document.getElementById("time").value;
        var dayom = document.getElementById("dayom").value;
        var month = document.getElementById("month").value;
        var year = document.getElementById("year").value;
        var day = document.getElementById("day").value;

        window.location = "address/" + name + day + "-" + dayom + "-" + month + "-" + year + "-" time + ".html";
    }
</script>
<style>
    input{
        display:block;
    }
</style>
</head>
<body>
    Name: <input id="name"/>
    Time: <input id="time"/>
    Day of the Month <input id="dayom"/>
    Month: <input id="month"/>
    Year: <input id="year"/>
    Day: <input id="day"/>
    <button onclick="showFile()">Take me to the file</button>
</body>
</html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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