source: trunk/MagicSoft/Mars/datacenter/db/sources.php@ 7546

Last change on this file since 7546 was 7546, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.6 KB
Line 
1<?php
2{
3 function CreateQuery($_GET, $alias)
4 {
5
6 $query0 = "SELECT ";
7 if ($_GET["fLinks"]=="Off" || !empty($_GET["fSendTxt"]))
8 $query0 .= " fSourceName as 'Source' ";
9 else
10 {
11 $query0 .= " CONCAT('<A&ws;HREF=\"sequinfo.php?', ";
12 $query0 .= " 'fRunStart=On', '&fZenithDistanceMin=On', '&fNumEvents=On', '&fRunTime%2F60=On', '&fSequenceLast=On', ";
13 $query0 .= " '&fSequenceFileWrittenStatus=0', '&fAllFilesAvail=On', '&fAllFilesAvailStatus=0', '&fCallisto=On', '&fCallistoStatus=0', '&fStar=On', '&fStarStatus=0', '&fFillCallistoStatus=0', '&fFillStarStatus=0', ";
14 $query0 .= " '&fSourceName=On', '&fSourceKEY=', fSourceKEY, "; //'&fRunMin=0', '&fRunMax=1000000', ";
15 $query0 .= " '&fNumResults=500\">', fSourcename, '</A>') ";
16 $query0 .= " as 'Source' ";
17 }
18 $query0 .= " , fSourceKEY as 'KEY', fTest as 'Test' ";
19 $query0 .= " FROM Source ";
20
21 if ($_GET["fTest"]=="Off")
22 $query0 .= " WHERE fTest='no'";
23
24 if ($_GET["fOff"]=="Off")
25 {
26 if (strpos($query0, " WHERE ")==FALSE)
27 $query0 .= " WHERE ";
28 else
29 $query0 .= " AND ";
30
31 $query0 .= " NOT (fSourceName like '%Off%')";
32 }
33
34 if (!empty($_GET["fSortBy"]))
35 {
36 $query0 .= " ORDER BY " . substr($_GET["fSortBy"], 0, -1) . " ";
37 if (substr($_GET["fSortBy"], -1)=="-")
38 $query0 .= "DESC";
39 }
40 else
41 $query0 .= " ORDER BY fSourceKEY ";
42
43 return $query0;
44 }
45
46 function InitGet($_GET)
47 {
48
49 if (empty($_GET["fTest"]))
50 $_GET["fTest"]="Off";
51
52 if (empty($_GET["fOff"]))
53 $_GET["fOff"]="Off";
54
55 if (empty($_GET["fLinks"]))
56 $_GET["fLinks"]="On";
57
58 }
59
60 function PrintForm($_GET)
61 {
62 printf("<center>\n");
63 printf("<form action=\"sources.php\" METHOD=\"GET\">\n");
64 printf(" <p><table>\n");
65 printf(" <tr>\n");
66
67 CheckBox("fOff", "incl. offsources");
68 CheckBox("fTest", "incl. test-sources");
69 CheckBox("fLinks", "links");
70
71 printf(" </table></p>\n");
72
73
74 ini_set("mysql.trace_mode", "Off");
75 ini_set("display_errors", "Off");
76
77 printf("<input class='Width' type='submit' value='Query Table'>&nbsp;&nbsp;&nbsp;\n");
78 printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"sources.php\"'>&nbsp;&nbsp;&nbsp;\n");
79 if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
80 printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
81 printf("</form>\n");
82 printf("</center>\n");
83 printf("</td>\n");
84 printf("</tr>\n");
85 printf("<tr class='Block'>\n");
86 printf("<td>\n");
87 }
88
89 function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign)
90 {
91 $db_id = mysql_connect($host, $user, $pw);
92 if ($db_id==FALSE)
93 {
94 printf("mysql_connect returned the following error: %s\n", mysql_error());
95 die("");
96 }
97 mysql_select_db($db);
98
99 $query0 = CreateQuery($_GET, $alias);
100
101 $result0 = mysql_query($query0, $db_id);
102
103 if ($result0)
104 {
105 if ($html=="1")
106 PrintMagicTable($result0, $alias, $rightalign, "", "", $_GET);
107 else
108 PrintText($result0);
109
110 mysql_free_result($result0);
111 }
112 mysql_close($db_id);
113
114 if ($html=="1")
115 printf("<U><B>submitted query:</B></U><BR>%s<BR>", htmlspecialchars($query0));
116 }
117
118 include ("include.php");
119 include ("db.php");
120 include ("magicdefs.php");
121
122 ini_set("display_errors", "On");
123 ini_set("mysql.trace_mode", "On");
124
125 if (!empty($_GET["fSendTxt"]))
126 {
127 header("Content-type: application/octet");
128 header("Content-Disposition: attachment; filename=query-result.txt");
129
130 PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign);
131 }
132 else
133 {
134 echo (file_get_contents("index-header.html"));
135
136 $environment = sizeof($_GET);
137
138 InitGet($_GET);
139 PrintForm($_GET);
140
141 if ($environment==0)
142 printf("No query submitted yet.<BR>");
143 else
144 PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign);
145
146 echo (file_get_contents("index-footer.html"));
147 }
148
149 ini_set("display_errors", "Off");
150 ini_set("mysql.trace_mode", "Off");
151}
152?>
Note: See TracBrowser for help on using the repository browser.