Changeset 13315 for trunk/Mars/datacenter
- Timestamp:
- 04/05/12 13:07:37 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/datacenter/db/run_comment.php
r12931 r13315 12 12 13 13 if (empty($_GET["fRunID"])) 14 $_GET["fRunID"]="001"; 14 $_GET["fRunID"]="all"; 15 16 if (empty($_GET["fSequenceID"])) 17 $_GET["fSequenceID"]="all"; 18 19 if (empty($_GET["fTable"])) 20 { 21 $_GET["fTable"]="RunComments"; 22 // $_GET["fTable"]="SequenceComments"; 23 $sign=strpos($_SERVER['REQUEST_URI'], "?")==false ? "?" : "&"; 24 $_SERVER['REQUEST_URI']=$_SERVER['REQUEST_URI'] . $sign . "fTable=RunComments"; 25 } 15 26 16 27 if (empty($_GET["fNight"])) … … 19 30 if (strcmp($_GET["fMode"], "tooltip")!=0) 20 31 echo (file_get_contents("index-header.html")); 21 22 32 23 33 … … 52 62 //for insert 53 63 if (strcmp($_GET["fMode"], "insert")==0) 54 $query0 = "INSERT RunCommentsSET ";64 $query0 = "INSERT " . $_GET["fTable"] . " SET "; 55 65 //for update 56 66 if (strcmp($_GET["fMode"], "update")==0) 57 $query0 = "UPDATE RunCommentsSET ";67 $query0 = "UPDATE " . $_GET["fTable"] . " SET "; 58 68 //for both 59 69 $query0.= " fComment='".str_replace("'", "\'", $_GET["fComment"])."'"; … … 63 73 { 64 74 $query0.=", fNight=".$_GET["fNight"]; 65 $query0.= ", fRunID=".$_GET["fRunID"]; 75 if (strcmp($_GET["fTable"], "RunComments")==0) 76 $query0.= ", fRunID=".$_GET["fRunID"]; 77 if (strcmp($_GET["fTable"], "SequenceComments")==0) 78 $query0.= ", fSequenceID=".$_GET["fSequenceID"]; 66 79 } 67 80 //for update 68 81 if (strcmp($_GET["fMode"], "update")==0) 69 82 { 70 $query2="SELECT fCommentKEY FROM RunComments ";83 $query2="SELECT fCommentKEY FROM " . $_GET["fTable"]; 71 84 $query2.=" WHERE fNight=".$_GET["fNight"]; 72 $query2.=" AND fRunID=".$_GET["fRunID"]; 85 if (strcmp($_GET["fTable"], "RunComments")==0) 86 $query2.=" AND fRunID=".$_GET["fRunID"]; 87 if (strcmp($_GET["fTable"], "SequenceComments")==0) 88 $query2.=" AND fSequenceID=".$_GET["fSequenceID"]; 73 89 $query2.=" AND fComment='".str_replace("'", "\'", $_GET["fOldComment"])."'"; 74 90 $result2=mysql_query($query2, $db_id); … … 78 94 $query0.=" WHERE fCommentKEY=".$commentkey; 79 95 } 96 //echo "insert query: " . $query0 . "<br>"; 80 97 $result0=mysql_query($query0, $db_id); 81 98 mysql_close($db_id); … … 91 108 if (strcmp($_GET["fMode"], "tooltip")!=0) 92 109 { 110 //mode 93 111 printf("With this page, you can \n"); 94 112 //view mode 95 113 if (strcmp($_GET["fMode"], "view")==0) 96 printf(" view,\n");114 printf("<b>view</b>,\n"); 97 115 else 98 116 printf("<a href='%s'>view</a>,\n", str_replace($_GET["fMode"], 'view', $_SERVER['REQUEST_URI'])); 99 117 //update mode 100 118 if (strcmp($_GET["fMode"], "update")==0) 101 printf(" updateand\n");119 printf("<b>update</b> and\n"); 102 120 else 103 121 printf("<a href='%s'>update</a> and \n", str_replace($_GET["fMode"], 'update', $_SERVER['REQUEST_URI'])); 104 122 //insert mode 105 123 if (strcmp($_GET["fMode"], "insert")==0) 106 printf(" insert\n");124 printf("<b>insert</b>\n"); 107 125 else 108 126 printf("<a href='%s'>insert</a> \n", str_replace($_GET["fMode"], 'insert', $_SERVER['REQUEST_URI'])); 109 printf("entries in the table <b>RunComment</b> from the DB <b>%s</b>.<br><br>\n", $db); 110 111 //insert field for run number 127 128 //table 129 printf("entries in the tables <b>%s</b> \n", $_GET["fTable"]); 130 if (strcmp($_GET["fTable"], "RunComments")==0) 131 printf(" and <a href='%s'>SequenceComments</a> \n", str_replace($_GET["fTable"], 'SequenceComments', $_SERVER['REQUEST_URI'])); 132 else 133 printf(" and <a href='%s'>RunComments</a> \n", str_replace($_GET["fTable"], 'RunComments', $_SERVER['REQUEST_URI'])); 134 //database 135 printf("from the DB %s.<br><br>\n", $db); 136 137 //insert field for run/sequence number 112 138 printf("<form action=\"run_comment.php\" METHOD=\"GET\">\n"); 113 printf("Run# (YYYYMMDD_FFF) <input name=\"fNight\" type=\"text\" size=\"8\" maxlength=\"8\" value=\"%s\">\n", $_GET["fNight"]); 114 printf("_ <input name=\"fRunID\" type=\"text\" size=\"3\" maxlength=\"3\" value=\"%s\">\n", $_GET["fRunID"]); 139 if (strcmp($_GET["fTable"], "RunComments")==0) 140 { 141 printf("Run# (YYYYMMDD_FFF) <input title='Enter here Night in the format YYYYMMDD or \"all\" to query all comments.' name=\"fNight\" type=\"text\" size=\"8\" maxlength=\"8\" value=\"%s\">\n", $_GET["fNight"]); 142 printf("_ <input title='Enter here RunID in the format FFF or \"all\" (only viewing mode) to query all comments of one night.' name=\"fRunID\" type=\"text\" size=\"3\" maxlength=\"3\" value=\"%s\">\n", $_GET["fRunID"]); 143 } 144 if (strcmp($_GET["fTable"], "SequenceComments")==0) 145 { 146 printf("Sequence# (YYYYMMDD_FFF) <input title='Enter here Night in the format YYYYMMDD or \"all\" to query all comments.' name=\"fNight\" type=\"text\" size=\"8\" maxlength=\"8\" value=\"%s\">\n", $_GET["fNight"]); 147 printf("_ <input title='Enter here SequenceID in the format FFF or \"all\" (only viewing mode) to query all comments of one night.' name=\"fSequenceID\" type=\"text\" size=\"3\" maxlength=\"3\" value=\"%s\">\n", $_GET["fSequenceID"]); 148 } 115 149 printf("<input type='hidden' name='fMode' value='%s'>", $_GET["fMode"]); 150 printf("<input type='hidden' name='fTable' value='%s'>", $_GET["fTable"]); 116 151 printf("<input type='submit' value='Get Comments'><br><br>\n"); 117 152 printf("</form>\n"); 118 153 } 119 154 155 if (!(preg_match("/20[0-9][0-9][01][0-9][0-3][0-9]/",$_GET["fNight"]) 156 || (preg_match("/all/",$_GET["fNight"]) && strcmp($_GET["fMode"], "view")==0))) 157 { 158 printf("-%s-<br>", $_GET["fMode"]); 159 printf("Please enter a valid number for the Night (format: YYYYMMDD)."); 160 return; 161 } 162 163 if (strcmp($_GET["fTable"], "RunComments")==0 && 164 (!(preg_match("/[0-9][0-9][0-9]/",$_GET["fRunID"]) 165 || (preg_match("/all/",$_GET["fRunID"]) && strcmp($_GET["fMode"], "view")==0)))) 166 { 167 printf("Please enter a valid number for the RunID (format: FFF, e.g. 001)."); 168 return; 169 } 170 171 if (strcmp($_GET["fTable"], "SequenceComments")==0 && 172 (!(preg_match("/[0-9][0-9][0-9]/",$_GET["fSequenceID"]) 173 || (preg_match("/all/",$_GET["fSequenceID"]) && strcmp($_GET["fMode"], "view")==0)))) 174 { 175 printf("Please enter a valid number for the SequenceID (format: FFF, e.g. 001)."); 176 return; 177 } 178 120 179 $db_id = mysql_pconnect($host, $user, $pw); 121 180 if ($db_id==FALSE) … … 126 185 mysql_select_db($db); 127 186 128 $query1 = "SELECT CONCAT(fNight,'_', LPAD(fRunID, 3, 0)), fComment FROM RunComments "; 129 $query1 .= "WHERE fNight=".$_GET["fNight"]." AND fRunID=".$_GET["fRunID"]; 187 if (strcmp($_GET["fTable"], "RunComments")==0) 188 $query1 = "SELECT CONCAT(fNight,'_', LPAD(fRunID, 3, 0))"; 189 if (strcmp($_GET["fTable"], "SequenceComments")==0) 190 $query1 = "SELECT CONCAT(fNight,'_', LPAD(fSequenceID, 3, 0))"; 191 $query1 .= ", fComment FROM " . $_GET["fTable"] . " "; 192 193 if (strcmp($_GET["fNight"], "all")!=0) 194 { 195 $query1 .= "WHERE fNight=".$_GET["fNight"]; 196 if (strcmp($_GET["fTable"], "RunComments")==0) 197 if (strcmp($_GET["fRunID"], "all")!=0) 198 $query1 .=" AND fRunID=".$_GET["fRunID"]; 199 if (strcmp($_GET["fTable"], "SequenceComments")==0) 200 if (strcmp($_GET["fSequenceID"], "all")!=0) 201 $query1 .=" AND fSequenceID=".$_GET["fSequenceID"]; 202 } 203 if (strcmp($_GET["fTable"], "RunComments")==0) 204 $query1 .= " ORDER BY fNight, fRunID, fCommentKEY "; 205 if (strcmp($_GET["fTable"], "SequenceComments")==0) 206 $query1 .= " ORDER BY fNight, fSequenceID, fCommentKEY "; 207 208 //printf("Query: %s <br>\n\n", $query1); 130 209 $result1=mysql_query($query1, $db_id); 131 210 printf("Found %d comment(s).\n\n", mysql_num_rows($result1)); … … 158 237 printf("<input type='hidden' name='fNight' value='%s'>\n", $_GET["fNight"]); 159 238 printf("<input type='hidden' name='fRunID' value='%s'>\n", $_GET["fRunID"]); 239 printf("<input type='hidden' name='fSequenceID' value='%s'>\n", $_GET["fSequenceID"]); 240 printf("<input type='hidden' name='fTable' value='%s'>\n", $_GET["fTable"]); 160 241 printf("<input type='submit' value='Update Comment'>\n"); 161 242 printf("</td>\n"); … … 167 248 } 168 249 else 169 printf("%s_%s: %s\n", $_GET["fNight"], $_GET["fRunID"], $row1[1]); 250 { 251 if (strcmp($_GET["fTable"], "RunComments")==0) 252 printf("%s_%s: %s\n", $_GET["fNight"], $_GET["fRunID"], $row1[1]); 253 if (strcmp($_GET["fTable"], "SequenceComments")==0) 254 printf("%s_%s: %s\n", $_GET["fNight"], $_GET["fSequenceID"], $row1[1]); 255 } 170 256 } 171 257 //insert mode … … 173 259 { 174 260 printf("<tr BGCOLOR='#C0C0C0'>"); 175 printf("<td>%s_%s</td>\n", $_GET["fNight"], $_GET["fRunID"]); 261 if (strcmp($_GET["fTable"], "RunComments")==0) 262 printf("<td>%s_%s</td>\n", $_GET["fNight"], $_GET["fRunID"]); 263 if (strcmp($_GET["fTable"], "SequenceComments")==0) 264 printf("<td>%s_%s</td>\n", $_GET["fNight"], $_GET["fSequenceID"]); 176 265 printf("<td>\n"); 177 266 printf("<form style='display:inline' action=\"run_comment.php\" METHOD=\"GET\">\n"); … … 180 269 printf("<input type='hidden' name='fNight' value='%s'>\n", $_GET["fNight"]); 181 270 printf("<input type='hidden' name='fRunID' value='%s'>\n", $_GET["fRunID"]); 271 printf("<input type='hidden' name='fSequenceID' value='%s'>\n", $_GET["fSequenceID"]); 272 printf("<input type='hidden' name='fTable' value='%s'>\n", $_GET["fTable"]); 182 273 printf("<input type='submit' value='Insert Comment'>\n"); 183 274 printf("</form>\n");
Note:
See TracChangeset
for help on using the changeset viewer.