raman Posted May 24, 2009 Share Posted May 24, 2009 I have a PHP script with HTML embedded in it. The PHP script takes time to run, so I want to add an intermediate page which would should show a progress bar and a message of my choice. Can someone tell how I can do this ? Will it be done by Javascript or PHP and where to add the code for the progress bar. Here is my PHP code: <html> <head><link href="lipo.css" rel="stylesheet" type="text/css" media="all"><script type="text/javascript" src="selctall.jsp"> </script></head> <body> <br> <table align="center" bgcolor="skyblue" width="60%"><tr> <th align="left"> <img src="calycin2.gif" height="130"></img>             <img src="banner.jpg" height="130"></img>          <img src="icgeb_logo1.jpg" height="130"></img></th></tr></table><table align="left" height="50%"><tr><td> </td></tr><tr><td> </td></tr><tr><td> <div id="main"> <div class="leftnav"> <ul class="listnone"> <li class="first"><a href="lipohome.html">Home</a></li> <li><a href="submit.html">Submit</a></li> <li><a href="algorithm.html">Algorithm</a></li> <li><a href="blast/viroblast.php">BLAST search</a></li> <li><a href="help.html">Help</a></li> <li><a href="team.html">Team</a></li> </ul></div></div> </td></tr></table><br> <DIV STYLE="position:absolute; left:330px; width:200px; height:25px"> <CENTER><FONT SIZE="+2" COLOR="00ff00"></FONT></CENTER> <!-----------------------------PHP script --------------------!> <?php echo "<table align='left' width=650 frame='void' cellspacing=1 cellpadding=3 border=0>"; echo "<tr><td height =20></td></tr>"; ########################### Setting Veriables ############################## $randi=rand(0, 1111111); $seq=$_POST['seq']; $userfile=$_FILES['userfile']['tmp_name']; $hybpred=$_POST['hybpred']; $sscpred=$_POST['sscpred']; $pfams=$_POST['pfam']; $pthresh=$_POST['pthresh']; $sscthresh=$_POST['sscthresh']; $hybthresh=$_POST['hybthresh']; $seqfile= $randi; ########################### Writing Input Seq into file ######################### $pattern = '/>/'; if (preg_match($pattern,$seq)) { $somecontent=$seq; } else { $somecontent = ">sequence\n".$seq; } $freq=0; // Let's make sure the file exists and is writable first. if (!is_writable("$seqfile")) { if (!$handle = fopen("./junkbin/$seqfile", 'w')) { echo "Cannot open file ($seqfile)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { ++$freq; //echo "Cannot write to file ($seqfile)"; exit; } //echo "Success, wrote ($somecontent) to file ($seqfile)"; fclose($handle); } ######################## get_svm_results() function call in IF-ESLE ################################# if($seq == '' && $userfile == ''){ echo "<TR><TD><font color='#d11010' size=5><br><p align='center'><blink><b>Warning !</b> </blink><br> Please type/paste either sequence/sequences or upload a sequence file from the browser!!</font></p></TD></TR> "; }elseif($seq == ''){ $file_data= implode("",file($userfile)); $sqfile="junkbin/".$randi; $f=fopen("$sqfile","w"); fwrite($f,$file_data); fclose($f); echo "<TR><TD bgcolor='skyblue' width='100%' Align=middle colspan='3'><font size =5.5 color ='AF250A'><b>PREDICTION RESULT<TD></TR><TR><TD><BR></TD></TR>"; echo "<TR><TD width=30%><font size=4><b>Your Job ID is </TD><TD width=5%>:</TD><TD>$randi</TD></TR>"; get_svm_result($randi,$sqfile,$sscthresh,$hybthresh,$pthresh,$hybpred,$sscpred,$pfam); }elseif($userfile == ''){ $sqfile= "junkbin/"."$seqfile"; echo "<TR ><TD bgcolor='skyblue' width='100%' Align=middle colspan='3'><font size =5.5 color='AF250A'><b>PREDICTION RESULT<TD></TR><TR><TD><BR></TD></TR>"; echo "<TR ><TD width=30%><font size=4><b>Your Job ID is </TD><TD width=5%>:</TD><TD>$randi</TD></TR>"; get_svm_result($randi,$sqfile,$sscthresh,$hybthresh,$pthresh,$hybpred,$sscpred,$pfam); }else{ echo "<TR><TD><font color='#d11010' size=4><br><br><br><img src='e001.gif'> <blink><br><br><font color='#d11010' size=5>Error !!</blink> either upload file from browser or type/paste your sequence in Text area !</font></TD></TR>"; } ######################## FUNCTION get_svm_result() ################################# function get_svm_result($randi,$sqfile,$sscthresh,$hybthresh,$pthresh,$hybpred,$sscpred){ #====================== Executing system commands ======================# $sqfile="junkbin/".$randi; $outfile="outputs/".'scores'.$randi; $testDetails_out=$randi.'testDetails.out';$testDetails1_out=$randi.'testDetails1.out'; $outfilecp='outfile'.$randi.'cp'; $outfilecp1='outfile1'.$randi.'cp'; $hybmodelfile="finl_models/".'pssm-ssc-model'; $modelfile = "finl_models/".'ssc-model'; $scorefile=$randi.'hybscore'; $sscscore=$randi.'sscscore'; $outfile2= 'allseqssc_'.$randi; $outfilea='finlf'.$randi; $outfile3='finlflll'.$randi; $outfile4='svmpat1_'.$randi; $outfile5='ps-ssc'.$randi; system("cat prefile $seqfile endfile > $yrfile"); echo "<TR><TD width=30%><font size=4><b>Your input seq(s) </TD><TD width=5%>:</TD><TD><a href='$sqfile'>Input file</a></TD>"; $myinput='4pssm'.$randi; system("cp $sqfile /usr/local/apache2/htdocs/lipocalinpred/$myinput"); if(!empty($hybpred) || (!empty($sscpred))){ system("sh fasta.sh $myinput"); system("perl lipopred.pl $myinput $randi"); } if(!empty($hybpred)){ system("perl ssc-normon.pl $outfile2 $randi"); system("paste -d '' $outfile4 $outfilea > $outfile5"); system("./svm_classify $outfile5 $hybmodelfile $scorefile >> $testDetails_out"); system("perl threshold_check.pl $scorefile $hybthresh > outputs/$outfilecp"); } if(!empty($sscpred)){ system("perl ssc-norm.pl $outfile2 $randi"); system("./svm_classify $outfile3 $modelfile $sscscore >> $testDetails1_out"); system("perl threshold_check.pl $sscscore $sscthresh > outputs/$outfilecp1"); } ############################################################################# $sno=$randi.'sno'; $tmpid=$randi.'tmpid'; $seqid=$randi.'seqid'; $download=$randi.'downld'; system("cat $sqfile |grep '>' |nl> outputs/$seqid"); `perl -pi -e "s/\>//g" outputs/$seqid`; `perl -pi -e "s/^ +//" outputs/$seqid`; `perl -pi -e "s/ /\t/" outputs/$seqid`; `cut -f 1 outputs/$seqid >outputs/$sno`; `cut -f 2 outputs/$seqid >outputs/$tmpid`; `perl -pi -e "s/\cM//g" outputs/$seqid`; # `paste outputs/$seqid outfile outputs/$outfilecp > outputs/$download`; echo "<TR><TD colspan=3><font size=3 color='red'><b><i>Note: </font><font size=3>Higher the SVM score, better is the confidence level of prediction. The confidence can also be taken care by using a high value of 'threshold' at submission page.</b></i></font><br><br></TD>"; # echo "<TR><TD align=center colspan=3><a href=outputs/$download><p align='right'>Download result</a></p>"; echo "<TABLE width='80%' bgcolor='pink' border='1' text='F5F4B1'></tr>"; echo "<tr bgcolor='B70B4D'><td width=20% align=middle><font color ='F6F8CC'><b>S.No.</td><td width=50% align=middle><font color ='F6F8CC'><b>Sequence IDs</td><td width=40% align=middle><font color ='F5F4B1'><b>SVM Score</td><td width=60% align=middle><font color ='F5F4B1'><b>Decision</td></font></tr>"; if(!empty($hybpred)){ echo"<tr><td width='50%'><font size=4 color=blue>PSSM+SSC model</font></td></tr>"; echo "<tr bgcolor='#FFFFFF' onMouseOver=\"bgr_color(this,'lightyellow')\" onMouseOut=\"bgr_color(this,'#FFFFFF')\">"; echo "<td width=20% align=left>"; system("cat prefile outputs/$sno endfile"); echo "</td><td width=50% align=left>"; system("cat prefile outputs/$tmpid endfile"); echo "</td><td width=40% align=middle>"; system("cat prefile $scorefile endfile"); echo "</td><td width=40% align=middle>"; system("cat prefile outputs/$outfilecp endfile"); echo"</td></tr>"; } if(isset($sscpred)){ echo"<tr><td width='50%'><font size=4 color=blue>SSC model</font></td></tr>"; echo "<tr bgcolor='#FFFFFF' onMouseOver=\"bgr_color(this,'lightyellow')\" onMouseOut=\"bgr_color(this,'#FFFFFF')\">"; echo "<td width=20% align=left>"; system("cat prefile outputs/$sno endfile"); echo "</td><td width=50% align=left>"; system("cat prefile outputs/$tmpid endfile"); echo "</td><td width=40% align=middle>"; system("cat prefile $sscscore endfile"); echo "</td><td width=40% align=middle>"; system("cat prefile outputs/$outfilecp1 endfile"); echo"</td></tr>"; } echo "<tr><td width=40% align=middle>"; echo "</td></tr></TABLE>"; echo "</DIV></html>"; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.