1 | <?php
|
---|
2 |
|
---|
3 | //arrays and functions for plot.php and plotdb.php
|
---|
4 | include("include.php");
|
---|
5 | include("magicdefs.php");
|
---|
6 | include("db.php");
|
---|
7 |
|
---|
8 | $tables=array("fSequenceFirst" => "Sequences",
|
---|
9 | "fRunNumber" => "RunData",
|
---|
10 | "fDataSetNumber" => "DataSets");
|
---|
11 |
|
---|
12 | $prims=array("SequenceNumber" => "fSequenceFirst",
|
---|
13 | "RunNumber" => "fRunNumber",
|
---|
14 | "DataSetNumber" => "fDataSetNumber");
|
---|
15 |
|
---|
16 | $joins=array("fSequenceFirst" => " LEFT JOIN Star ON Star.fSequenceFirst=Sequences.fSequenceFirst "
|
---|
17 | ."LEFT JOIN Calibration ON Calibration.fSequenceFirst=Sequences.fSequenceFirst",
|
---|
18 | "fRunNumber" => " LEFT JOIN DataCheck ON DataCheck.fRunNumber=RunData.fRunNumber ",
|
---|
19 | "fDataSetNumber" =>" LEFT JOIN Ganymed ON Ganymed.fDataSetNumber=DataSets.fDataSetNumber");
|
---|
20 |
|
---|
21 | function GetList($host, $user, $pw, $db, $column, $tables)
|
---|
22 | {
|
---|
23 | $tab_fSequenceFirst=array("Sequences", "Calibration", "Star");
|
---|
24 | $tab_fRunNumber=array("RunData");
|
---|
25 | $tab_fDataSetNumber=array("DataSets", "Ganymed");
|
---|
26 |
|
---|
27 | $table=$tables[$column];
|
---|
28 | foreach(${"tab_".$column} as $tab)
|
---|
29 | {
|
---|
30 | $query="EXPLAIN " . $tab;
|
---|
31 |
|
---|
32 | mysql_connect($host, $user, $pw);
|
---|
33 | mysql_select_db($db);
|
---|
34 |
|
---|
35 | $result=mysql_query($query);
|
---|
36 |
|
---|
37 | while ($row = mysql_fetch_row($result))
|
---|
38 | $list[] = $row[0];
|
---|
39 | }
|
---|
40 | return $list;
|
---|
41 | }
|
---|
42 |
|
---|
43 | function GetQuery($tables, $joins, $set)
|
---|
44 | {
|
---|
45 | if (empty($_GET["prim"]))
|
---|
46 | $_GET["prim"]="";
|
---|
47 | $primary=$_GET["prim"];
|
---|
48 | if (empty($primary))
|
---|
49 | return "";
|
---|
50 | if (empty($_GET[$primary."Col"]))
|
---|
51 | $_GET[$primary."Col"]="";
|
---|
52 | $column=$_GET[$primary."Col"];
|
---|
53 | $table=$tables[$primary];
|
---|
54 | if (empty($_GET["primstart"]))
|
---|
55 | $_GET["primstart"]="";
|
---|
56 | $primstart=$_GET["primstart"];
|
---|
57 | if (empty($_GET["primstop"]))
|
---|
58 | $_GET["primstop"]="";
|
---|
59 | $primstop=$_GET["primstop"];
|
---|
60 | if (empty($_GET[$column."Start"]))
|
---|
61 | $_GET[$column."Start"]="";
|
---|
62 | $start1=$_GET[$column."Start"];
|
---|
63 | if (empty($_GET[$column."Stop"]))
|
---|
64 | $_GET[$column."Stop"]="";
|
---|
65 | $stop1=$_GET[$column."Stop"];
|
---|
66 |
|
---|
67 | $query="SELECT " . $table . "." . $primary . ", ";
|
---|
68 | if ($column==$primary)
|
---|
69 | $query.=$table . "." . $column;
|
---|
70 | else
|
---|
71 | $query.=$column;
|
---|
72 |
|
---|
73 | if ($_GET["plot"]=="val")
|
---|
74 | {
|
---|
75 | if (empty($_GET[$primary."Col2"]))
|
---|
76 | $_GET[$primary."Col2"]="";
|
---|
77 | $column2=$_GET[$primary."Col2"];
|
---|
78 | if (empty($_GET[$column2."Start2"]))
|
---|
79 | $_GET[$column2."Start2"]="";
|
---|
80 | $start2=$_GET[$column2."Start2"];
|
---|
81 | if (empty($_GET[$column2."Stop2"]))
|
---|
82 | $_GET[$column2."Stop2"]="";
|
---|
83 | $stop2=$_GET[$column2."Stop2"];
|
---|
84 |
|
---|
85 | if ($column2==$primary)
|
---|
86 | $query.=", " . $table . "." . $column2;
|
---|
87 | else
|
---|
88 | $query.=", " . $column2;
|
---|
89 | }
|
---|
90 | $query.=" FROM " . $table;
|
---|
91 | $query.=$joins[$primary];
|
---|
92 | if (!empty($primstart) && !empty($primstop))
|
---|
93 | $query.=" WHERE " . $table . "." . $primary . " BETWEEN " . $primstart . " AND " . $primstop;
|
---|
94 |
|
---|
95 | if (!empty($start1) && !empty($stop1))
|
---|
96 | {
|
---|
97 | if (strpos($query, " WHERE ")==FALSE)
|
---|
98 | $query.=" WHERE " . $column . " BETWEEN " . $start1 . " AND " . $stop1;
|
---|
99 | else
|
---|
100 | $query.=" AND " . $column . " BETWEEN " . $start1 . " AND " . $stop1;
|
---|
101 | }
|
---|
102 |
|
---|
103 | if ($_GET["plot"]=="val" && !empty($start2) && !empty($stop2))
|
---|
104 | {
|
---|
105 | if (strpos($query, " WHERE ")==FALSE)
|
---|
106 | $query.=" WHERE " . $column2 . " BETWEEN " . $start2 . " AND " . $stop2;
|
---|
107 | else
|
---|
108 | $query.=" AND " . $column2 . " BETWEEN " . $start2 . " AND " . $stop2;
|
---|
109 | }
|
---|
110 |
|
---|
111 | if (!empty($set) && !empty($_GET[$set]))
|
---|
112 | {
|
---|
113 | if (strpos($query, " WHERE ")==FALSE)
|
---|
114 | $query .= " WHERE ";
|
---|
115 | else
|
---|
116 | $query.=" AND ";
|
---|
117 | $query.= $table . "." . $primary . " IN (" . str_replace(" ", ",", $_GET[$set]) . ") ";
|
---|
118 | }
|
---|
119 |
|
---|
120 | return $query;
|
---|
121 | }
|
---|
122 |
|
---|
123 | //functions for showplots.php and showplots2.php
|
---|
124 | function gettypename($type2)
|
---|
125 | {
|
---|
126 | switch ($type2)
|
---|
127 | {
|
---|
128 | case "calib":
|
---|
129 | $type="callisto";
|
---|
130 | break;
|
---|
131 | case "signal":
|
---|
132 | $type="callisto";
|
---|
133 | break;
|
---|
134 | case "star":
|
---|
135 | $type="star";
|
---|
136 | break;
|
---|
137 | }
|
---|
138 | return $type;
|
---|
139 | }
|
---|
140 |
|
---|
141 | function getplotname($seq, $tabnum, $type, $type2)
|
---|
142 | {
|
---|
143 | $seqlong=str_pad($seq, 8, "0", STR_PAD_LEFT);
|
---|
144 | $seqshort=substr($seqlong, 0, 4);
|
---|
145 | $plot = "http://datacenter.astro.uni-wuerzburg.de/";
|
---|
146 | $plot .= $type . "/" . str_pad( $seqshort, 4, "0", STR_PAD_LEFT);
|
---|
147 | $plot .= "/" . $seqlong . "/" . $type2 . $seqlong . "-tab" . $tabnum . ".png";
|
---|
148 | return $plot;
|
---|
149 | }
|
---|
150 |
|
---|
151 | ?>
|
---|