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("<input class='Width' type='submit' value='Query Table'> \n");
|
---|
23 | printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"queryrbk.php\"'> \n");
|
---|
24 | if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
|
---|
25 | printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'> \n", $_SERVER["REQUEST_URI"]);
|
---|
26 | printf("</form>\n");
|
---|
27 | printf("</center>\n");
|
---|
28 | printf("</td>\n");
|
---|
29 | printf("</tr>\n");
|
---|
30 | printf("<tr class='Block'>\n");
|
---|
31 | printf("<td>\n");
|
---|
32 | }
|
---|
33 |
|
---|
34 | function PrintPage($html, $host, $user, $pw, $db)
|
---|
35 | {
|
---|
36 | $db_id = mysql_connect($host, $user, $pw);
|
---|
37 | if ($db_id==FALSE)
|
---|
38 | {
|
---|
39 | printf("mysql_connect returned the following error: %s\n", mysql_error());
|
---|
40 | die("");
|
---|
41 | }
|
---|
42 | mysql_select_db($db);
|
---|
43 |
|
---|
44 | $query0 = "SELECT fRunBookDate AS Date, fRunBookText AS Entry ";
|
---|
45 | $query0 .= "FROM " . $db . ".RunBook ";
|
---|
46 | $query0 .= "WHERE fRunBookDate REGEXP '^" . $_GET["fDate"] . "' ";
|
---|
47 |
|
---|
48 | if (!empty($_GET["fRegexp"]))
|
---|
49 | $query0 .= "AND fRunBookText REGEXP '" . $_GET["fRegexp"] . "' ";
|
---|
50 |
|
---|
51 | $query0 .= "ORDER BY fRunBookDate";
|
---|
52 |
|
---|
53 | $result0 = mysql_query($query0, $db_id);
|
---|
54 |
|
---|
55 | if ($result0)
|
---|
56 | {
|
---|
57 | if ($html=="1")
|
---|
58 | {
|
---|
59 | $alias = array
|
---|
60 | (
|
---|
61 | "fRunBookDate" => "Date",
|
---|
62 | "fRunBookText" => "Entry"
|
---|
63 | );
|
---|
64 | $rightalign = array
|
---|
65 | (
|
---|
66 | );
|
---|
67 | PrintMagicTable($result0, $alias, $rightalign, "", "", $_GET);
|
---|
68 | }
|
---|
69 | else
|
---|
70 | PrintText($result0);
|
---|
71 |
|
---|
72 | mysql_free_result($result0);
|
---|
73 | }
|
---|
74 | mysql_close($db_id);
|
---|
75 |
|
---|
76 | if ($html=="1")
|
---|
77 | printf("<U><B>submitted query:</B></U><BR>%s<BR>", $query0);
|
---|
78 | }
|
---|
79 |
|
---|
80 | include ("include.php");
|
---|
81 | include ("db.php");
|
---|
82 |
|
---|
83 | ini_set("display_errors", "On");
|
---|
84 | ini_set("mysql.trace_mode", "On");
|
---|
85 |
|
---|
86 | if (!empty($_GET["fSendTxt"]))
|
---|
87 | {
|
---|
88 | header("Content-type: application/octet");
|
---|
89 | header("Content-Disposition: attachment; filename=query-result.txt");
|
---|
90 |
|
---|
91 | PrintPage("0", $host, $user, $pw, $db);
|
---|
92 | }
|
---|
93 | else
|
---|
94 | {
|
---|
95 | echo (file_get_contents("index-header.html"));
|
---|
96 |
|
---|
97 | $environment = sizeof($_GET);
|
---|
98 |
|
---|
99 | PrintForm($_GET);
|
---|
100 |
|
---|
101 | if ($environment==0)
|
---|
102 | printf("No query submitted yet.<BR>");
|
---|
103 | else
|
---|
104 | PrintPage("1", $host, $user, $pw, $db);
|
---|
105 |
|
---|
106 | echo (file_get_contents("index-footer.html"));
|
---|
107 | }
|
---|
108 |
|
---|
109 | ini_set("display_errors", "Off");
|
---|
110 | ini_set("mysql.trace_mode", "Off");
|
---|
111 | }
|
---|
112 | ?>
|
---|