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

Last change on this file since 7484 was 7484, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 3.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("<input class='Width' type='submit' value='Query Table'>&nbsp;&nbsp;&nbsp;\n");
23 printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"queryrbk.php\"'>&nbsp;&nbsp;&nbsp;\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\"'>&nbsp;&nbsp;&nbsp;\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, $db)
35 {
36 $db_id = mysql_connect("hercules.astro.uni-wuerzburg.de", "MAGIC", "d99swMT!");
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", $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", $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?>
Note: See TracBrowser for help on using the repository browser.