source: trunk/MagicSoft/Mars/datacenter/db/queryrbk.php@ 9463

Last change on this file since 9463 was 9184, checked in by Daniela Dorner, 16 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.3 KB
Line 
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&nbsp;(yyyy-mm-dd)&nbsp;<input name=\"fDate\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"");
12 printf("%s\">&nbsp;&nbsp;&nbsp;\n", $_GET["fDate"]);
13
14 printf("Search&nbsp;<A HREF=\"regexp.html\">regexp:</A>&nbsp;<input name=\"fRegexp\" type=\"text\" size=\"32\" maxlength=\"128\" value=\"");
15 if (!empty($_GET["fRegexp"]))
16 printf("%s", $_GET["fRegexp"]);
17 printf("\">&nbsp;&nbsp;&nbsp;\n<P>\n");
18
19 ini_set("mysql.trace_mode", "Off");
20 ini_set("display_errors", "Off");
21
22 printf("Night&nbsp;(yyyy-mm-dd)&nbsp;<input name=\"fNight\" type=\"text\" size=\"10\" maxlength=\"10\" value=\"");
23 printf("%s\">&nbsp;&nbsp;&nbsp;\n", $_GET["fNight"]);
24
25
26 printf("<input class='Width' type='submit' value='Query Table'>&nbsp;&nbsp;&nbsp;\n");
27 printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"queryrbk.php\"'>&nbsp;&nbsp;&nbsp;\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\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
31 printf("<input class='Width' type='button' value='Print' onClick='self.location.href=\"%s&amp;fPrintTable=1\"'>&nbsp;&nbsp;&nbsp;\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?>
Note: See TracBrowser for help on using the repository browser.