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

Last change on this file since 9445 was 8621, checked in by Daniela Dorner, 17 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.9 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-aio.php?', ";
12 $query0 .= " 'fRunStart=On', '&fZenithDistanceMin=On', '&fNumEvents=On', '&fRunTime%2F60=On', '&fSequenceLast=On', ";
13 $query0 .= " '&fSequenceFileWrittenStatus=0', '&fAllFilesAvailStatus=0', '&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["fSourceN"]))
35 {
36 if (strpos($query0, " WHERE ")==FALSE)
37 $query0 .= " WHERE ";
38 else
39 $query0 .= " AND ";
40
41 $query0 .= " fSourceName REGEXP \"^" . $_GET["fSourceN"] . "\" ";
42 }
43
44
45 if (!empty($_GET["fSortBy"]))
46 {
47 $query0 .= " ORDER BY " . substr($_GET["fSortBy"], 0, -1) . " ";
48 if (substr($_GET["fSortBy"], -1)=="-")
49 $query0 .= "DESC";
50 }
51 else
52 $query0 .= " ORDER BY fSourceKEY ";
53
54 return $query0;
55 }
56
57 function InitGet($_GET)
58 {
59
60 if (empty($_GET["fOff"]))
61 $_GET["fOff"]="Off";
62
63 if (empty($_GET["fTest"]))
64 $_GET["fTest"]="Off";
65
66 if (empty($_GET["fLinks"]))
67 $_GET["fLinks"]="On";
68
69 }
70
71 function PrintForm($_GET,$host,$user,$pw,$db)
72 {
73 printf("<center>\n");
74 printf("<form action=\"sources.php\" METHOD=\"GET\">\n");
75 printf(" <p><table>\n");
76 printf(" <tr>\n");
77
78 CheckBox("fOff", "incl. offsources");
79 CheckBox("fTest", "incl. test-sources");
80 CheckBox("fLinks", "links");
81
82 printf(" </table></p>\n");
83 printf("<p>");
84 PrintSourceMenu($host,$user,$pw,$db);
85
86 ini_set("mysql.trace_mode", "Off");
87 ini_set("display_errors", "Off");
88
89 printf("<input class='Width' type='submit' value='Query Table'>&nbsp;&nbsp;&nbsp;\n");
90 printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"sources.php\"'>&nbsp;&nbsp;&nbsp;\n");
91 if (strchr($_SERVER["REQUEST_URI"], '?')!=FALSE)
92 printf("<input class='Width' type='button' value='Get .txt' onClick='self.location.href=\"%s&fSendTxt=1\"'>&nbsp;&nbsp;&nbsp;\n", $_SERVER["REQUEST_URI"]);
93 printf("</form>\n");
94 printf("</center>\n");
95 printf("</td>\n");
96 printf("</tr>\n");
97 printf("<tr class='Block'>\n");
98 printf("<td>\n");
99 }
100
101 function PrintPage($html, $host, $user, $pw, $db, $alias, $rightalign)
102 {
103 $db_id = mysql_connect($host, $user, $pw);
104 if ($db_id==FALSE)
105 {
106 printf("mysql_connect returned the following error: %s\n", mysql_error());
107 die("");
108 }
109 mysql_select_db($db);
110
111 $query0 = CreateQuery($_GET, $alias);
112
113 $result0 = mysql_query($query0, $db_id);
114
115 if ($result0)
116 {
117 if ($html=="1")
118 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);
119 else
120 PrintText($result0);
121
122 mysql_free_result($result0);
123 }
124 mysql_close($db_id);
125
126 PrintSubmittedQuery($query0, $html, $db, "old");
127 }
128
129 include ("include.php");
130 include ("menu.php");
131 include ("db.php");
132 include ("magicdefs.php");
133
134 ini_set("display_errors", "On");
135 ini_set("mysql.trace_mode", "On");
136
137 if (!empty($_GET["fSendTxt"]))
138 {
139 header("Content-type: application/octet");
140 header("Content-Disposition: attachment; filename=query-result.txt");
141
142 PrintPage("0", $host, $user, $pw, $db, $alias, $rightalign);
143 }
144 else
145 {
146 echo (file_get_contents("index-header.html"));
147
148 $environment = sizeof($_GET);
149
150 InitGet($_GET);
151 PrintForm($_GET,$host,$user,$pw,$db);
152
153 if ($environment==0)
154 printf("No query submitted yet.<BR>");
155 else
156 PrintPage("1", $host, $user, $pw, $db, $alias, $rightalign);
157
158 echo (file_get_contents("index-footer.html"));
159 }
160
161 ini_set("display_errors", "Off");
162 ini_set("mysql.trace_mode", "Off");
163}
164?>
Note: See TracBrowser for help on using the repository browser.