| 1 | <?php
|
|---|
| 2 | {
|
|---|
| 3 | function PrintPage($host, $user, $pw, $db)
|
|---|
| 4 | {
|
|---|
| 5 | $db_id = mysql_connect($host, $user, $pw);
|
|---|
| 6 | if ($db_id==FALSE)
|
|---|
| 7 | {
|
|---|
| 8 | printf("mysql_connect returned the following error: %s\n", mysql_error());
|
|---|
| 9 | die("");
|
|---|
| 10 | }
|
|---|
| 11 | mysql_select_db($db);
|
|---|
| 12 |
|
|---|
| 13 | $query1="SELECT MAX(fStartDate) FROM MarsVersion";
|
|---|
| 14 | $dateresult=mysql_query($query1);
|
|---|
| 15 | $row = mysql_fetch_row($dateresult);
|
|---|
| 16 | $date=$row[0];
|
|---|
| 17 | if (mysql_errno()>0)
|
|---|
| 18 | printf(" Error-Number: %s <br>", mysql_errno());
|
|---|
| 19 | if (mysql_error()!="")
|
|---|
| 20 | printf(" Error-Message: %s <br>", mysql_error());
|
|---|
| 21 | if (mysql_info()!="")
|
|---|
| 22 | printf(" Mysql-Info: %s <br>", mysql_info());
|
|---|
| 23 | mysql_free_result($dateresult);
|
|---|
| 24 | if (empty($date))
|
|---|
| 25 | {
|
|---|
| 26 | printf("Could not get date of latest Mars version from database.");
|
|---|
| 27 | return;
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | if (empty($_GET["insert"]))
|
|---|
| 31 | {
|
|---|
| 32 | $query0 = "SELECT fSequenceFirst, ";
|
|---|
| 33 | $query0 .= "if (fCallisto " . " < '" . $date . "', 'callisto to be resetted', ";
|
|---|
| 34 | $query0 .= "if (not isnull(fCallisto), 'callisto already processed with new release', ";
|
|---|
| 35 | $query0 .= "if (fStartTime > ADDDATE(Now(), INTERVAL -1 DAY) AND isnull(fFailedTime), 'callisto running',";
|
|---|
| 36 | $query0 .= "if (isnull(fFailedTime), 'callisto already resetted for new release', ";
|
|---|
| 37 | $query0 .= " 'callisto crashed or failed')))) as 'calstat', ";
|
|---|
| 38 | $query0 .= "if (fStar " . " < '" . $date . "', 'star to be resetted', ";
|
|---|
| 39 | $query0 .= "if (not isnull(fStar), 'star already processed with new release', ";
|
|---|
| 40 | $query0 .= "if (fStartTime > ADDDATE(Now(), INTERVAL -1 DAY) AND isnull(fFailedTime), 'star running',";
|
|---|
| 41 | $query0 .= "if (isnull(fFailedTime), 'star already resetted for new release', ";
|
|---|
| 42 | $query0 .= " 'star crashed or failed')))) as 'starstat' ";
|
|---|
| 43 | $query0 .= "FROM SequenceProcessStatus ";
|
|---|
| 44 | }
|
|---|
| 45 | else
|
|---|
| 46 | {
|
|---|
| 47 | $query0 = "UPDATE SequenceProcessStatus SET ";
|
|---|
| 48 | if ($_GET["step"]=="callisto")
|
|---|
| 49 | $query0 .="fCallisto=NULL, fFillCallisto=NULL, fStar=NULL, fFillStar=NULL, ";
|
|---|
| 50 | else
|
|---|
| 51 | if ($_GET["step"]=="star")
|
|---|
| 52 | $query0 .="fStar=NULL, fFillStar=NULL, ";
|
|---|
| 53 | $query0 .="fStartTime=NULL, fFailedTime=NULL, fFailedCode=NULL, fFailedCodeAdd=NULL, fReturnCode=NULL ";
|
|---|
| 54 |
|
|---|
| 55 | if ($_GET["step"]=="callisto")
|
|---|
| 56 | $query0 .= " WHERE fCallisto " . " < '" . $date . "'";
|
|---|
| 57 | else
|
|---|
| 58 | if ($_GET["step"]=="star")
|
|---|
| 59 | $query0 .= " WHERE fStar " . " < '" . $date . "'";
|
|---|
| 60 | else
|
|---|
| 61 | $query0 .= " WHERE (NOT ISNULL(fFailedTime) OR fStartTime < ADDDATE(Now(), INTERVAL -1 DAY))";
|
|---|
| 62 | }
|
|---|
| 63 | if (ereg("^([ ]*[0-9]{5,8}[ ]*[,])*[ ]*[0-9]{5,8}[ ]*$",$_GET["Seqs"]))
|
|---|
| 64 | {
|
|---|
| 65 | if (strpos($query0, " WHERE ")==FALSE)
|
|---|
| 66 | $query0 .= " WHERE ";
|
|---|
| 67 | else
|
|---|
| 68 | $query0 .= " AND ";
|
|---|
| 69 | $query0 .=" fSequenceFirst IN (" . $_GET["Seqs"] . ")";
|
|---|
| 70 | }
|
|---|
| 71 | else
|
|---|
| 72 | {
|
|---|
| 73 | echo "You have to give the sequences, which you want to reset, in the correct format, i.e. sequence numbers separated by ','.<br>";
|
|---|
| 74 | return;
|
|---|
| 75 | }
|
|---|
| 76 | if (empty($_GET["step"]))
|
|---|
| 77 | {
|
|---|
| 78 | echo "Please choose what you want to reset: <br>";
|
|---|
| 79 | echo "crashed processes (i.e. running longer than 1 day or failed), callisto or star.<br>";
|
|---|
| 80 | return;
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 | $result0=mysql_query($query0);
|
|---|
| 84 | if (mysql_errno()>0)
|
|---|
| 85 | printf(" Errorno: %s <br>", mysql_errno());
|
|---|
| 86 | if (mysql_error()!="")
|
|---|
| 87 | printf(" Errormsg: %s <br>", mysql_error());
|
|---|
| 88 | if (!empty($_GET["insert"]) && !empty($_GET["step"]))
|
|---|
| 89 | {
|
|---|
| 90 | printf("%s Sequences have been resetted. <br><br>\n", mysql_affected_rows());
|
|---|
| 91 | if (mysql_info()!="")
|
|---|
| 92 | printf("Mysql-Info: %s <br><br>\n", mysql_info());
|
|---|
| 93 | }
|
|---|
| 94 | else
|
|---|
| 95 | {
|
|---|
| 96 | if (mysql_affected_rows()==0)
|
|---|
| 97 | {
|
|---|
| 98 | echo "No sequence to reset.<br>";
|
|---|
| 99 | echo "The sequences you listed are already resetted.<br>";
|
|---|
| 100 | mysql_free_result($result0);
|
|---|
| 101 | return;
|
|---|
| 102 | }
|
|---|
| 103 | echo "The status of the sequences you entered: <br>\n";
|
|---|
| 104 | $star="";
|
|---|
| 105 | $callisto="";
|
|---|
| 106 | $crashed="";
|
|---|
| 107 | $calcolor='black';
|
|---|
| 108 | $starcolor='black';
|
|---|
| 109 | $style='normal';
|
|---|
| 110 | $col = FALSE;
|
|---|
| 111 | $bgcolor='#C0C0C0';
|
|---|
| 112 | printf("<table border='0'>\n");
|
|---|
| 113 | printf("<tr bgcolor='%s'>\n<th style='padding-left:1ex;padding-right:1ex'>\n<u>Sequence</u>\n</th>\n<th>\n<u>Status Callisto</u>\n</th>\n<th>\n<u>Status Star</u>\n</th>\n</tr>\n", $bgcolor);
|
|---|
| 114 | while ($row = mysql_fetch_row($result0))
|
|---|
| 115 | {
|
|---|
| 116 | if ($row[2]=='star to be resetted' && $_GET["step"]=='star')
|
|---|
| 117 | {
|
|---|
| 118 | $star[]=$row[0];
|
|---|
| 119 | $starcolor='green';
|
|---|
| 120 | $style='bold';
|
|---|
| 121 | }
|
|---|
| 122 | if ($row[1]=='callisto to be resetted' && $_GET["step"]=='callisto')
|
|---|
| 123 | {
|
|---|
| 124 | $callisto[]=$row[0];
|
|---|
| 125 | $calcolor='green';
|
|---|
| 126 | $style='bold';
|
|---|
| 127 | }
|
|---|
| 128 | if (($row[1]=='callisto crashed or failed' || $row[2]=='star crashed or failed') && $_GET["step"]=='crashed')
|
|---|
| 129 | {
|
|---|
| 130 | $crashed[]=$row[0];
|
|---|
| 131 | if ($row[1]=='callisto crashed or failed')
|
|---|
| 132 | {
|
|---|
| 133 | $calcolor='green';
|
|---|
| 134 | $style='bold';
|
|---|
| 135 | }
|
|---|
| 136 | else
|
|---|
| 137 | {
|
|---|
| 138 | $starcolor='green';
|
|---|
| 139 | $style='bold';
|
|---|
| 140 | }
|
|---|
| 141 | }
|
|---|
| 142 | if (!$col)
|
|---|
| 143 | $bgcolor='#E0E0E0';
|
|---|
| 144 | else
|
|---|
| 145 | $bgcolor='#D0D0D0';
|
|---|
| 146 | $col = !$col;
|
|---|
| 147 | printf("<tr bgcolor='%s'>\n<td align='center' style='font-weight:%s'>\n%s \n</td>\n", $bgcolor, $style, $row[0]);
|
|---|
| 148 | printf("<td style='padding-left:1ex;padding-right:1ex'>\n <font color='%s'>%s </font>\n</td>\n", $calcolor, $row[1]);
|
|---|
| 149 | printf("<td style='padding-left:1ex;padding-right:1ex'>\n <font color='%s'>%s </font>\n</td>\n</tr>\n", $starcolor, $row[2]);
|
|---|
| 150 | $calcolor='black';
|
|---|
| 151 | $starcolor='black';
|
|---|
| 152 | $style='normal';
|
|---|
| 153 | }
|
|---|
| 154 | printf("</table>\n");
|
|---|
| 155 |
|
|---|
| 156 | if ($_GET["step"]=="crashed")
|
|---|
| 157 | printf("<br>\n You chose to reset only the sequences which are crashed or failed.<br>\n");
|
|---|
| 158 | else
|
|---|
| 159 | printf("<br>\n Only the sequences which have not yet been processed or resetted, will be resetted.<br>\n");
|
|---|
| 160 | printf("To <b>reset</b> them, please check the insert checkbox and submit again.<br><br>\n");
|
|---|
| 161 |
|
|---|
| 162 | if (empty($star) && empty($callisto) && empty($crashed))
|
|---|
| 163 | echo "With your choice no sequences would be resetted.";
|
|---|
| 164 | else
|
|---|
| 165 | echo "With your choice the following sequences would be resetted: ";
|
|---|
| 166 | if (!empty($star))
|
|---|
| 167 | foreach($star as $num => $seq)
|
|---|
| 168 | echo $seq . " ";
|
|---|
| 169 | if (!empty($callisto))
|
|---|
| 170 | foreach($callisto as $num => $seq)
|
|---|
| 171 | echo $seq . " ";
|
|---|
| 172 | if (!empty($crashed))
|
|---|
| 173 | foreach($crashed as $num => $seq)
|
|---|
| 174 | echo $seq . " ";
|
|---|
| 175 | mysql_free_result($result0);
|
|---|
| 176 | printf("<br>\n<br>\n<input type='button' value='Reset Sequences' onClick='self.location.href=\"%s&insert=On\"'> \n", htmlspecialchars($_SERVER["REQUEST_URI"]));
|
|---|
| 177 | }
|
|---|
| 178 | mysql_close($db_id);
|
|---|
| 179 |
|
|---|
| 180 | // PrintSubmittedQuery($query0, "1", $db, "old");
|
|---|
| 181 |
|
|---|
| 182 | }
|
|---|
| 183 |
|
|---|
| 184 | include ("include.php");
|
|---|
| 185 | include ("menu.php");
|
|---|
| 186 | include ("db.php");
|
|---|
| 187 | include ("magicdefs.php");
|
|---|
| 188 |
|
|---|
| 189 | ini_set("display_errors", "On");
|
|---|
| 190 | ini_set("mysql.trace_mode", "On");
|
|---|
| 191 |
|
|---|
| 192 | echo (file_get_contents("index-header.html"));
|
|---|
| 193 |
|
|---|
| 194 | $ips=array("91.64.78.187", "132.187.47.10", "132.187.47.67");
|
|---|
| 195 | if (!in_array($_SERVER['REMOTE_ADDR'], $ips))
|
|---|
| 196 | {
|
|---|
| 197 | echo "You are not allowed to reset sequences.<br>";
|
|---|
| 198 | echo "If you want to reset your sequences in the automatic analysis, please contact Daniela Dorner.<br>";
|
|---|
| 199 | echo (file_get_contents("index-footer.html"));
|
|---|
| 200 | return;
|
|---|
| 201 | }
|
|---|
| 202 |
|
|---|
| 203 | $environment = sizeof($_GET);
|
|---|
| 204 |
|
|---|
| 205 | //init
|
|---|
| 206 | if (empty($_GET["Seqs"]))
|
|---|
| 207 | $_GET["Seqs"]="";
|
|---|
| 208 | if (empty($_GET["step"]))
|
|---|
| 209 | $_GET["step"]="";
|
|---|
| 210 |
|
|---|
| 211 | //print form
|
|---|
| 212 | printf("<center>\n");
|
|---|
| 213 | printf("<form action=\"resetseq.php\" METHOD=\"GET\">\n");
|
|---|
| 214 |
|
|---|
| 215 | printf("<input type='radio' name='step' value='crashed' %s> crashed processes ", $_GET["step"]=="crashed" ? "checked" : "");
|
|---|
| 216 | printf("<input type='radio' name='step' value='callisto' %s> callisto ", $_GET["step"]=="callisto" ? "checked" : "");
|
|---|
| 217 | printf("<input type='radio' name='step' value='star' %s> star<br>", $_GET["step"]=="star" ? "checked" : "");
|
|---|
| 218 |
|
|---|
| 219 | printf("<table>\n<tr>\n<td align='left'>\nSequences: \n</td>\n</td>\n</tr>\n<tr>\n<td valign='left'>\n");
|
|---|
| 220 | printf("<input name='Seqs' type='text' size='75' maxlength='300' value='%s'>\n</td>\n</tr>\n</table>\n<br>\n", $_GET["Seqs"]);
|
|---|
| 221 |
|
|---|
| 222 | ini_set("mysql.trace_mode", "Off");
|
|---|
| 223 | // ini_set("display_errors", "Off");
|
|---|
| 224 |
|
|---|
| 225 | printf("<input type='submit' value='Reset Sequences in DB'> \n");
|
|---|
| 226 | printf("<input class='Width' type='button' value='Reset' onClick='self.location.href=\"resetseq.php\"'> \n");
|
|---|
| 227 | // if (!empty($_GET["step"]) && ereg("^([ ]*[0-9]{5,8}[ ]*[,])*[ ]*[0-9]{5,8}[ ]*$",$_GET["Seqs"]))
|
|---|
| 228 | // printf("<input type='checkbox' name='insert' value='On'>insert\n");
|
|---|
| 229 | printf("<br>\n");
|
|---|
| 230 | printf("</form>\n");
|
|---|
| 231 | printf("</center>\n");
|
|---|
| 232 | printf("</td>\n</tr>\n");
|
|---|
| 233 | printf("<tr class='Block'>\n<td>\n");
|
|---|
| 234 |
|
|---|
| 235 | if ($environment==0)
|
|---|
| 236 | {
|
|---|
| 237 | printf("No query submitted yet.<br>\n");
|
|---|
| 238 | printf("To reset sequences, please insert them in the following format: <i>12345,87654321</i><br>\n");
|
|---|
| 239 | printf("and choose whether you want to reset just crashed processes, callisto (this includes star) or just star.<br>\n");
|
|---|
| 240 | printf("You can enter up to 300 characters in the sequences field.<br>\n");
|
|---|
| 241 | }
|
|---|
| 242 | else
|
|---|
| 243 | PrintPage($host, $user, $pw, $db);
|
|---|
| 244 |
|
|---|
| 245 | echo (file_get_contents("index-footer.html"));
|
|---|
| 246 |
|
|---|
| 247 | ini_set("display_errors", "Off");
|
|---|
| 248 | ini_set("mysql.trace_mode", "Off");
|
|---|
| 249 | }
|
|---|
| 250 | ?>
|
|---|