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

Last change on this file since 7979 was 7974, checked in by Daniela Dorner, 18 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 3.8 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 printf("<input class='Width' type='submit' value='Query Table'>&nbsp;&nbsp;&nbsp;\n");
26 printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"queryrbk.php\"'>&nbsp;&nbsp;&nbsp;\n");
27 if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
28 printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
29 printf("</form>\n");
30 printf("</center>\n");
31 printf("</td>\n");
32 printf("</tr>\n");
33 printf("<tr class='Block'>\n");
34 printf("<td>\n");
35 }
36
37 function PrintPage($html, $host, $user, $pw, $db)
38 {
39 $db_id = mysql_connect($host, $user, $pw);
40 if ($db_id==FALSE)
41 {
42 printf("mysql_connect returned the following error: %s\n", mysql_error());
43 die("");
44 }
45 mysql_select_db($db);
46
47 $query0 = "SELECT fRunBookDate AS Date, fRunBookText AS Entry ";
48 $query0 .= "FROM " . $db . ".RunBook ";
49 $query0 .= "WHERE fRunBookDate REGEXP '^" . $_GET["fDate"] . "' ";
50
51 if (!empty($_GET["fRegexp"]))
52 $query0 .= "AND fRunBookText REGEXP '" . $_GET["fRegexp"] . "' ";
53
54 if (!empty($_GET["fNight"]))
55 $query0 .= "AND fRunBookDate < '" . $_GET["fNight"] . " 13:00:00' AND fRunBookDate > ADDDATE( '" . $_GET["fNight"] . " 13:00:00', INTERVAL -1 DAY) ";
56
57 $query0 .= "ORDER BY fRunBookDate";
58
59 $result0 = mysql_query($query0, $db_id);
60
61 if ($result0)
62 {
63 if ($html=="1")
64 {
65 $alias = array
66 (
67 "fRunBookDate" => "Date",
68 "fRunBookText" => "Entry"
69 );
70 $rightalign = array
71 (
72 );
73 PrintMagicTable($result0, $alias, $rightalign, "", "", "", $_GET);
74 }
75 else
76 PrintText($result0);
77
78 mysql_free_result($result0);
79 }
80 mysql_close($db_id);
81
82 PrintSubmittedQuery($query0, $html, $db, "old");
83 }
84
85 include ("include.php");
86 include ("db.php");
87
88 ini_set("display_errors", "On");
89 ini_set("mysql.trace_mode", "On");
90
91 if (!empty($_GET["fSendTxt"]))
92 {
93 header("Content-type: application/octet");
94 header("Content-Disposition: attachment; filename=query-result.txt");
95
96 PrintPage("0", $host, $user, $pw, $db);
97 }
98 else
99 {
100 echo (file_get_contents("index-header.html"));
101
102 $environment = sizeof($_GET);
103
104 PrintForm($_GET);
105
106 if ($environment==0)
107 printf("No query submitted yet.<BR>");
108 else
109 PrintPage("1", $host, $user, $pw, $db);
110
111 echo (file_get_contents("index-footer.html"));
112 }
113
114 ini_set("display_errors", "Off");
115 ini_set("mysql.trace_mode", "Off");
116}
117?>
Note: See TracBrowser for help on using the repository browser.