1

这对我来说有点复杂:假设我的服务器有 1200 个文件,例如:

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等等

可以看到它们每个都有一个名称:WRTR 和 BRTR 以及日期和时间。我必须用 php mysql javascript 编写一个脚本(只有最后不得已),让用户输入日期时间和名称(wrtr 或 brtr),他将能够查看相应的文件。谁能建议如何进行?

根据建议并在 maxhud 的帮助下,我得到了这个,向你致敬......

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

和 php 脚本: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>

并确认.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';

 }

?>      
4

1 回答 1

1
<!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>
于 2012-07-07T20:01:09.197 回答