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

Last change on this file since 9509 was 9498, checked in by Daniela Dorner, 15 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.4 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 SQL_CALC_FOUND_ROWS 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 $result1 = mysql_query("SELECT FOUND_ROWS()", $db_id);
66
67 if ($result0)
68 {
69 if ($html=="1" || $html=="2")
70 {
71 $alias = array
72 (
73 "fRunBookDate" => "Date",
74 "fRunBookText" => "Entry"
75 );
76 $rightalign = array
77 (
78 );
79 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $result1);
80 }
81 else
82 PrintText($result0);
83
84 mysql_free_result($result0);
85 mysql_free_result($result1);
86 }
87 mysql_close($db_id);
88
89 PrintSubmittedQuery($query0, $html, $db, "old");
90 }
91
92 include ("include.php");
93 include ("db.php");
94
95 ini_set("display_errors", "On");
96 ini_set("mysql.trace_mode", "On");
97
98 if (!empty($_GET["fSendTxt"]))
99 {
100 header("Content-type: application/octet");
101 header("Content-Disposition: attachment; filename=query-result.txt");
102
103 PrintPage("0", $host, $user, $pw, $db);
104 }
105 else
106 {
107 if (empty($_GET["fPrintTable"]))
108 echo (file_get_contents("index-header.html"));
109
110 $environment = sizeof($_GET);
111
112 if (empty($_GET["fPrintTable"]))
113 PrintForm($_GET);
114
115 if ($environment==0)
116 printf("No query submitted yet.<BR>");
117 else
118 {
119 if (empty($_GET["fPrintTable"]))
120 PrintPage("1", $host, $user, $pw, $db);
121 else
122 PrintPage("2", $host, $user, $pw, $db);
123 }
124
125 if (empty($_GET["fPrintTable"]))
126 echo (file_get_contents("index-footer.html"));
127 }
128
129 ini_set("display_errors", "Off");
130 ini_set("mysql.trace_mode", "Off");
131}
132?>
Note: See TracBrowser for help on using the repository browser.