| 1 | <?php
|
|---|
| 2 | {
|
|---|
| 3 | function PrintForm($_GET)
|
|---|
| 4 | {
|
|---|
| 5 | if (empty($_GET["fDate"]))
|
|---|
| 6 | $_GET["fDate"]=date("Y-m-d");
|
|---|
| 7 |
|
|---|
| 8 | printf("<center>\n");
|
|---|
| 9 | printf("<form action=\"queryrbk.php\" METHOD=\"GET\">\n");
|
|---|
| 10 |
|
|---|
| 11 | printf("Date (yyyy-mm-dd) <input name=\"fDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"");
|
|---|
| 12 | printf("%s\"> \n", $_GET["fDate"]);
|
|---|
| 13 |
|
|---|
| 14 | printf("Search <A HREF=\"regexp.html\">regexp:</A> <input name=\"fRegexp\" type=\"text\" size=\"32\" maxlength=\"128\" value=\"");
|
|---|
| 15 | if (!empty($_GET["fRegexp"]))
|
|---|
| 16 | printf("%s", $_GET["fRegexp"]);
|
|---|
| 17 | printf("\"> \n<P>\n");
|
|---|
| 18 |
|
|---|
| 19 | ini_set("mysql.trace_mode", "Off");
|
|---|
| 20 | ini_set("display_errors", "Off");
|
|---|
| 21 |
|
|---|
| 22 | printf("Night (yyyy-mm-dd) <input name=\"fNight\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"");
|
|---|
| 23 | printf("%s\"> \n", $_GET["fNight"]);
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 | printf("<input class='Width' type='submit' value='Query Table'> \n");
|
|---|
| 27 | printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"queryrbk.php\"'> \n");
|
|---|
| 28 | if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
|
|---|
| 29 | {
|
|---|
| 30 | printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'> \n", $_SERVER["REQUEST_URI"]);
|
|---|
| 31 | printf("<input class='Width' type='button' value='Print' onClick='self.location.href=\"%s&fPrintTable=1\"'> \n", htmlspecialchars($_SERVER["REQUEST_URI"]));
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | printf("</form>\n");
|
|---|
| 35 | printf("</center>\n");
|
|---|
| 36 | printf("</td>\n");
|
|---|
| 37 | printf("</tr>\n");
|
|---|
| 38 | printf("<tr class='Block'>\n");
|
|---|
| 39 | printf("<td>\n");
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | function PrintPage($html, $host, $user, $pw, $db)
|
|---|
| 43 | {
|
|---|
| 44 | $db_id = mysql_connect($host, $user, $pw);
|
|---|
| 45 | if ($db_id==FALSE)
|
|---|
| 46 | {
|
|---|
| 47 | printf("mysql_connect returned the following error: %s\n", mysql_error());
|
|---|
| 48 | die("");
|
|---|
| 49 | }
|
|---|
| 50 | mysql_select_db($db);
|
|---|
| 51 |
|
|---|
| 52 | $query0 = "SELECT fRunBookDate AS Date, fRunBookText AS Entry ";
|
|---|
| 53 | $query0 .= "FROM " . $db . ".RunBook ";
|
|---|
| 54 | $query0 .= "WHERE fRunBookDate REGEXP '^" . $_GET["fDate"] . "' ";
|
|---|
| 55 |
|
|---|
| 56 | if (!empty($_GET["fRegexp"]))
|
|---|
| 57 | $query0 .= "AND fRunBookText REGEXP '" . $_GET["fRegexp"] . "' ";
|
|---|
| 58 |
|
|---|
| 59 | if (!empty($_GET["fNight"]))
|
|---|
| 60 | $query0 .= "AND fRunBookDate < '" . $_GET["fNight"] . " 13:00:00' AND fRunBookDate > ADDDATE( '" . $_GET["fNight"] . " 13:00:00', INTERVAL -1 DAY) ";
|
|---|
| 61 |
|
|---|
| 62 | $query0 .= "ORDER BY fRunBookDate";
|
|---|
| 63 |
|
|---|
| 64 | $result0 = mysql_query($query0, $db_id);
|
|---|
| 65 |
|
|---|
| 66 | if ($result0)
|
|---|
| 67 | {
|
|---|
| 68 | if ($html=="1" || $html=="2")
|
|---|
| 69 | {
|
|---|
| 70 | $alias = array
|
|---|
| 71 | (
|
|---|
| 72 | "fRunBookDate" => "Date",
|
|---|
| 73 | "fRunBookText" => "Entry"
|
|---|
| 74 | );
|
|---|
| 75 | $rightalign = array
|
|---|
| 76 | (
|
|---|
| 77 | );
|
|---|
| 78 | PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);
|
|---|
| 79 | }
|
|---|
| 80 | else
|
|---|
| 81 | PrintText($result0);
|
|---|
| 82 |
|
|---|
| 83 | mysql_free_result($result0);
|
|---|
| 84 | }
|
|---|
| 85 | mysql_close($db_id);
|
|---|
| 86 |
|
|---|
| 87 | PrintSubmittedQuery($query0, $html, $db, "old");
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | include ("include.php");
|
|---|
| 91 | include ("db.php");
|
|---|
| 92 |
|
|---|
| 93 | ini_set("display_errors", "On");
|
|---|
| 94 | ini_set("mysql.trace_mode", "On");
|
|---|
| 95 |
|
|---|
| 96 | if (!empty($_GET["fSendTxt"]))
|
|---|
| 97 | {
|
|---|
| 98 | header("Content-type: application/octet");
|
|---|
| 99 | header("Content-Disposition: attachment; filename=query-result.txt");
|
|---|
| 100 |
|
|---|
| 101 | PrintPage("0", $host, $user, $pw, $db);
|
|---|
| 102 | }
|
|---|
| 103 | else
|
|---|
| 104 | {
|
|---|
| 105 | if (empty($_GET["fPrintTable"]))
|
|---|
| 106 | echo (file_get_contents("index-header.html"));
|
|---|
| 107 |
|
|---|
| 108 | $environment = sizeof($_GET);
|
|---|
| 109 |
|
|---|
| 110 | if (empty($_GET["fPrintTable"]))
|
|---|
| 111 | PrintForm($_GET);
|
|---|
| 112 |
|
|---|
| 113 | if ($environment==0)
|
|---|
| 114 | printf("No query submitted yet.<BR>");
|
|---|
| 115 | else
|
|---|
| 116 | {
|
|---|
| 117 | if (empty($_GET["fPrintTable"]))
|
|---|
| 118 | PrintPage("1", $host, $user, $pw, $db);
|
|---|
| 119 | else
|
|---|
| 120 | PrintPage("2", $host, $user, $pw, $db);
|
|---|
| 121 | }
|
|---|
| 122 |
|
|---|
| 123 | if (empty($_GET["fPrintTable"]))
|
|---|
| 124 | echo (file_get_contents("index-footer.html"));
|
|---|
| 125 | }
|
|---|
| 126 |
|
|---|
| 127 | ini_set("display_errors", "Off");
|
|---|
| 128 | ini_set("mysql.trace_mode", "Off");
|
|---|
| 129 | }
|
|---|
| 130 | ?>
|
|---|