<html>
<head>
<meta http-equiv="Content-Type" content="text/html">
<title>:: rip ::</title>
</head>
<script language="javascript">
function Close_Show(){
var parameters="toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizeable=0,height=600,width=800";
var runpath=document.forms[0].CmbBoxRunDate.value;
runpath=runpath.replace("/","_");
runpath=runpath.replace("/","_");
runpath=runpath+"/"+document.forms[0].CmbBoxRunRun.value;
RipRunName=document.forms[0].RipRunName.value;
addr="cgi/ripout.php?gpath="+runpath+"&rrunname="+RipRunName;
ripWindow=open(addr,"newDocument",parameters);
window.close();
}
function RefereshDetail(){
var index=document.forms[0].CmbBoxRunDate.selectedIndex;
var folder=document.forms[0].CmbBoxRunDate.options[index].text;
var index=document.forms[0].CmbBoxRunRun.selectedIndex;
var subFolder=document.forms[0].CmbBoxRunRun.options[index].text;
detailFrame.location.href="detail.php?folder="+folder+"&subFolder="+subFolder;
}
</script>
<?php
function Java(){
print "<script language=\"javascript\">
function WhenDateSelect(){";
$fp=fopen("/mm5/backup/run_dates","r");
while( !feof($fp) ){
$line=fgets($fp,1024);
if($line=="")break;
$line=str_replace("\n","",$line);
$line=str_replace("/","_",$line);
print "var D$line=[";
$fpn=fopen("/mm5/backup/$line/runs","r");
$run=fgets($fpn,1024);
$run=str_replace("\n","",$run);
print "\"$run\"";
while( !feof($fpn) ){
$run=fgets($fpn,1024);
if($run=="")break;
print ",";
$run=str_replace("\n","",$run);
print "\"$run\"";
}
print "];";
fclose($fpn);
}
print "var DatesSTR=[";
$fp=fopen("/mm5/backup/run_dates","r");
$line=fgets($fp,1024);
$line=str_replace("\n","",$line);
$line=str_replace("/","_",$line);
print "\"D$line\"";
while( !feof($fp) ){
$line=fgets($fp,1024);
if($line=="")break;
print ",";
$line=str_replace("\n","",$line);
$line=str_replace("/","_",$line);
print "\"D$line\"";
}
print "];";
fclose($fp);
print "var DatesTWO=[";
$fp=fopen("/mm5/backup/run_dates","r");
$line=fgets($fp,1024);
$line=str_replace("\n","",$line);
$line=str_replace("/","_",$line);
print "D$line";
while( !feof($fp) ){
$line=fgets($fp,1024);
if($line=="")break;
print ",";
$line=str_replace("\n","",$line);
$line=str_replace("/","_",$line);
print "D$line";
}
print "];";
fclose($fp);
print "var selecteditem=document.forms[0].CmbBoxRunDate.value;
if(selecteditem==null)selecteditem=DatesSTR[0];";
print "else {
removeOptions();";
print " newstr=selecteditem.replace(\"/\",\"_\");
newstr=newstr.replace(\"/\",\"_\");
arrayname=\"D\"+newstr;
}
var itemindex=0;
while( arrayname!=DatesSTR[itemindex] ) itemindex++;
var i=0;
while(i<DatesTWO[itemindex].length){
addOption(DatesTWO[itemindex][i],\"item\"+i);
i++;
}
RefereshDetail()
}";
print "function removeOptions(){
while(document.forms[0].CmbBoxRunRun.length != 0)
document.forms[0].CmbBoxRunRun.remove(0);
}
function addOption(text, value){
var oOption = document.createElement(\"OPTION\");
oOption.text=text;
oOption.value=text;
document.forms[0].CmbBoxRunRun.add(oOption);
};";
print "function AddtoCmbBox(){;
var Dates=[";
$fp=fopen("/mm5/backup/run_dates","r");
$line=fgets($fp,1024);
$line=str_replace("\n","",$line);
print "\"$line\"";
while( !feof($fp) ){
$line=fgets($fp,1024);
if($line=="")break;
print ",";
$line=str_replace("\n","",$line);
print "\"$line\"";
}
print "];";
fclose($fp);
print "var i=0;
while(i<Dates.length ){
var oOption = document.createElement(\"OPTION\");
oOption.text=Dates[i];
oOption.value=Dates[i];
document.forms[0].CmbBoxRunDate.add(oOption);
i++;
}
WhenDateSelect();
};";
print "</script>";
}
Java();
if(!isset($BtnRun)){
print "<body background=\"images/barbkgde.gif\" onload=\"AddtoCmbBox()\">
<form action=\"rip.php\" method=\"post\">
<select size=\"1\" name=\"CmbBoxRunDate\" onchange=\"WhenDateSelect()\"></select>
<select size=\"1\" name=\"CmbBoxRunRun\" onchange=\"RefereshDetail()\"></select>
<p> Enter Rip run name: <input type=\"text\" name=\"RipRunName\" maxlength=\"4\" size=\"2\"></p>
<p><input type=\"submit\" value=\"Run Rip\" name=\"BtnRun\"></p></form>";
print "<br><center>
<iframe src=\"blank.html\" name=\"detailFrame\" width=\"620\" height=\"600\" scrolling=\"1\"
frameborder=\"0\"></iframe></center>";
}
else{
echo "<body background=\"images/barbkgde.gif\">";
/*@check for unique rip run name for this date*/
$archive_path=split("[/.-]",$CmbBoxRunDate);
$ERROR=0;
$ErrorAry=array();
if (file_exists("/mm5/archive/$archive_path[0]/$archive_path[1]/$archive_path[2]/rip/runs") ){
$fp=fopen("/mm5/archive/$archive_path[0]/$archive_path[1]/$archive_path[2]/rip/runs","r");
while(!feof($fp)){
$rec=fgets($fp,1024);
$rec=str_replace("\n","",$rec);
if( $rec==$RipRunName)
{$ERROR=1;array_push($ErrorAry,"$RipRunName already exist, please change it.");}
}
fclose($fp);
}
if($RipRunName=="" or ereg("[?!#$%^&*()=:+,;><@|~`\"\' ]",$RipRunName)){
$ERROR=1;
array_push($ErrorAry,"$RipRunName is invalid , please correct it.");
}
if($ERROR==1){
print "<h2>The following errors has been occured...</h2>";
for($i=0;$i<sizeof($ErrorAry);$i++)print "<p><font color=red><b>§</b> $ErrorAry[$i]</font></p>";
die("<input type=\"button\" value=\"Back\" name=\"btnBack\" onclick=\"javascript:history.back(1)\">");
}
else{
echo "<form>
<input type=\"hidden\" value=\"$RipRunName\" name=\"RipRunName\">
<input type=\"hidden\" value=\"$CmbBoxRunRun\" name=\"CmbBoxRunRun\">
<input type=\"hidden\" value=\"$CmbBoxRunDate\" name=\"CmbBoxRunDate\">
</form>";
echo " <script language=\"javascript\">
Close_Show();
</script>";
}
/**/
}
?>
</body>
</html>