A Plastic Futures Trading Program Analysis Chart program (Php+java)

Source: Internet
Author: User
Tags explode rar sleep split thread tostring stringbuffer

Php+java the program of ............

Java Program:

/*
The following procedure is a timing tracing analysis program for the futures trading data of Yuyao Plastics city
is a preliminary analysis of the data, drawing analysis to the further PHP program to complete
This procedure is completed in 2005-5-17 (Friendship Day)
This procedure can be used as chart original database
*/
Import java.net.*;
Import java.io.*;
Import java.nio.*;
Import java.text.*;
Import java.util.*;
Import Java.util.Date;
Import java.util.regex.*;
Class Suliao
{
final static int line=11;
public static void Main (String args[])
{
String url= "Http://www.ex-cp.com//yy_data/quot.txt";
String url1= "Http://www.51kk7.com/Forum/User/CompanyInfo.aspx?companyId=0";
for (;;)
{
Try
{
Thread.Sleep (10000);
String Ori[][]=new string[line][14];
int sta=0;
//
for (;;)
{
Thread.Sleep (1000);
Date date;
SimpleDateFormat hua=new SimpleDateFormat ("H m S");
String Time=hua.format (date=new date ());
String[] Hua1=time.split ("\s");
int I=integer.parseint (hua1[0]) *3600+integer.parseint (hua1[1]) *60+integer.parseint (hua1[2));
if (i<34100)
Break
if (i>39900)
Break
URL hp=new url (url);
URLConnection hpcon=hp.openconnection ();
int Len=hpcon.getcontentlength ();
InputStream Input=hpcon.getinputstream ();
int C;
StringBuffer hu=new StringBuffer ("");
String Hu1[]=new String[line];
int k=0;
while (((C=input.read ())!=-1) && (--len>0))
{
if (c==10)
{
Hu1[k]=hu.tostring ();
Hu=new StringBuffer ("");
k++;
}
Else
{
Char c1= (char) C;
Hu.append (C1);
}
}
Hu1[line-1]=hu.tostring ();
String Hu2[][]=new string[line][14];
Suliao he=new Suliao ();
for (int k1=0;k1<line;k1++)
Hu2[k1]=he.zz (Hu1[k1]);
/*
for (int k2=0;k2<10;k2++)
{
for (int k3=0;k3<14;k3++)
System.out.print (hu2[k2][k3]+ "T");
System.out.println ("");
}
*/
int K2;
if (sta==0)
{
ORI=HU2;
Sta=1;
for (k2=0;k2<line;k2++)
He.writeinfo (Hu2[k2],i);
}
else if (sta==1)
{
He.writeinfo (Hu2[0]);
Let ' s start the Compare Program,go go
for (k2=0;k2<line;k2++)
{
System.out.println (hu2[k2][12]+ "-" +ori[k2][12]);
if (true)//he.zv (hu2[k2][12])!=he.zv (ori[k2][12))
{
He.writeinfo (Hu2[k2],i);
}
}
ORI=HU2;
}
}
//
}
catch (Exception e)
{
System.out.println ("wrong wrong wrong!!!");
E.printstacktrace ();
}
}
}
Public string[] ZZ (String a)
{
String[] Hello=a.split ("\,");
for (int i=0;iHello[i]=hello[i].trim ();
return hello;
}
public int Zv (String a)
{
Return Integer.parseint (a);
}
public void Writeinfo (string[] a,int i)//write to the text database
{
Calendar cn=calendar.getinstance ();
int Mon=cn.get (calendar.month) +1;
String Dir=cn.get (calendar.year) + "-" +mon+ "-" +cn.get (Calendar.day_of_month);
String File=cn.get (calendar.year) + "-" +mon+ "-" +cn.get (calendar.day_of_month) + "/" +a[0]+ ". txt";
File Hu=new file (file);
File Ha=new file (dir);
Try
{
if (!ha.exists ())
Ha.mkdir ();
if (!hu.exists ())
Hu.createnewfile ();
Date date;
SimpleDateFormat hua=new SimpleDateFormat ("H m S");
String Time=hua.format (date=new date ());
String[] Hua1=time.split ("\s");
int I=integer.parseint (hua1[0]) *3600+integer.parseint (hua1[1]) *60+integer.parseint (hua1[2));
int k;
StringBuffer kv=new StringBuffer ("");
for (k=0;k<14;k++)
{
Kv.append (a[k]+ "T");
}
Kv.append (i+ "\ n");
System.out.println (Kv.tostring ());
FileWriter rar=new FileWriter (hu,true);
Rar.write (Kv.tostring ());
Rar.close ();
}
catch (Exception e)
{
E.printstacktrace ();
}
}
}

PHP Program

?
$GO =$_post[' Go '];
if (! $GO)
$GO =$_get[' Go '];
if ($GO ==1)
{
$dir =$_post[' time '];
$file 1=$_post[' file '];
$handle =opendir ('./'. $dir);
Print "<form action=index.php method=post>
<input Type=hidden Name=go value=1>
Time: <input type=\ "text\" value=\ "$dir \" readonly name=\ "time\"/>
Variety: <select name=file onchange=\ "This.form.submit ()" >
<option value=\ "> select variety </option>";
while ($file = Readdir ($handle)) {
if ($file!= ".") && ($file!= "..."))
{
$file =explode (".", $file);
$file = $file [0];
echo "<option value= $file > $file </option>";
}
}
print "</select></form>";
Closedir ($handle);
if ($file 1)
{
Print "}
}
ElseIf ($GO ==2)
{
Set_time_limit (10);
$time =$_get[' time '];
$file =$_get[' file ']. TXT ";
$file 1=explode (".", $file);
$STR = $file 1[0]. ': $time. ' Drawing Time ('. Date ("Y-m-d h:i:s").
$afile = "./". $time. " /". $file;
$a =file ($afile);
for ($i =0; $i <count ($a); $i + +)
{
$b =explode ("T", $a [$i]);
if ($i ==0)
{
$p = 0;
$hu [$p][0]= $b [12];
$hu [$p][1]= $b [13];
$hu [$p][2]= $b [14];
$p + +;
}
Else
{
$b 1=explode ("T", $a [$i-1]);
if ($b [12]!= $b 1[12])
{
$dis = $b [12]-$b 1[12];
$hu [$p][0]= $dis;
$hu [$p][1]= $b [13];
$hu [$p][2]= $b [14];
$p + +;
}
}
}
/*
echo "<table border=1><tr><td> turnover </td><td> quotes </td><td> times </td>< /tr> ";
for ($i =0; $i < $p; $i + +)
{
$h =floor ($hu [$i][2]/3600);
$h 1= $hu [$i][2]-$h *3600;
$m =floor ($h 1/60);
$s = $h 1-$m *60;
$TIME = $h. ': $m. ': $s;
echo "<tr><td>" $hu [$i][0]. " </td><td> ". $hu [$i][1]." </td><td> ". $TIME." </td></tr> ";
}
echo "</table>";
*/
Drawing start
Header ("Content-type:image/gif");
$im =imagecreate (600,400);
$backcolor =imagecolorallocate ($im, 236,236,236);
$linecolor 1=imagecolorallocate ($im, 255,0,0);//rise interval line, red
$linecolor 2=imagecolorallocate ($im, 0,255,0);//fall interval line, Green Line
$linecolor 3=imagecolorallocate ($im, 0,0,255);//flat interval line, Blue Line
$linecolor 4=imagecolorallocate ($im, 247,198,166);//Table line
$linecolor 5=imagecolorallocate ($im, 156,54,143);//quote Curve
$linecolor 4=imagecolorallocate ($im,,,);
Imagefill ($im, 0,0, $backcolor);
Ruler Line Start (part of Curve)
Imageline ($im, 30,10,30,110, $linecolor 1);
Imageline ($im, 30,110,30,210, $linecolor 2);
Imageline ($im, 30,110,570,110, $linecolor 3);
Imageline ($im, 570,110,570,10, $linecolor 1);
Imageline ($im, 570,110,570,210, $linecolor 2);
Imagestring ($im, 2,5,105,0, $linecolor 3);
Imagestring ($im, 2,572,105,0, $linecolor 3);
For ($i =0 $i <=4; $i + +)
{
$up = "+". ($i) *40;
$down = "-". ($i + 1) *40;
Imageline ($im, (10+20* $i), 570, (10+20* $i), $linecolor 4);
Imagestring ($im, 2,5, (5+20* $i), $up, $linecolor 1);
Imagestring ($im, 2,572, (5+20* $i), $up, $linecolor 1);
Imageline ($im, (130+20* $i), 570, (130+20* $i), $linecolor 4);
Imagestring ($im, 2,5, (125+20* $i), $down, $linecolor 2);
Imagestring ($im, 2,572, (125+20* $i), $down, $linecolor 2);
}
$t [0]= "9:30";
$t [1]= "9:45";
$t [2]= "10:00";
$t [3]= "10:15";
$t [4]= "10:30";
$t [5]= "10:45";
$t [6]= "11:00";
For ($i =0 $i <=6; $i + +)
{
if (($i!=0) && ($i!=6))
{
Imageline ($im, (30+90* $i), ten (30+90* $i), 210, $linecolor 4);
}
$t 1= $t [$i];
Imagestring ($im, 2, (15+90* $i), 212, $t 1, $linecolor 3);
}
Ruler line Start (volume portion)
For ($i =0 $i <=5; $i + +)
{
$ii =290+20* $i;
$III = ($i) *10;
Imageline ($im, $ii, 570, $ii, $linecolor 4);
Imagestring ($im, 2,5, $ii -5, $III, $linecolor 1);
Imagestring ($im, 2,575, $ii -5, ($iii *10), $linecolor 3);
}
Imageline ($im, 30,290,30,390, $linecolor 4);
Imageline ($im, 570,290,570,390, $linecolor 4);
For ($i =1 $i <=5; $i + +)
{
$ii =30+90* $i;
Imagedashedline ($im, $ii, 290, $ii, 390, $linecolor 4);
}
Ruler Line ends
Curve drawing begins
$a =file ($afile);
for ($i =0; $i <count ($a); $i + +)
{
$b =explode ("T", $a [$i]);
$b 1= $b [13];
$b 2= $b [14];
$x = ($b 2-34100)/10;
$y =-$b 1*0.5+110;
if ($i ==0)
{
$x 1= $x;
$y 1= $y;
}
Else
{
Imageline ($im, $x, $y, $x 1, $y 1, $linecolor 5);
$x 1= $x;
$y 1= $y;
}
}
Volume drawing started
$sum = 0;
for ($i =0; $i < $p; $i + +)
{
$y =390-2* $hu [$i][0];
$x = ($hu [$i][2]-34100)/10;
Imageline ($im, $x, 390, $x, $y, $linecolor 1);
$sum + + $hu [$i][0];
$ysum =390-0.2* $sum;
if ($i ==0)
{
$x 1= $x;
$y 1= $ysum;
}
Else
{
Imageline ($im, $x 1, $y 1, $x, $y 1, $linecolor 3);
Imageline ($im, $x, $y 1, $x, $ysum, $linecolor 3);
$x 1= $x;
$y 1= $ysum;
}
}
Imageline ($im, $x 1, $y 1,570, $y 1, $linecolor 3);
Settlement Price Curve Drawing
$sum = 0;
$allprice = 0;
for ($i =0; $i < $p; $i + +)
{
$sum + + $hu [$i][0];
$allprice + + $hu [$i][1]* $hu [$i][0];
if ($sum ==0) $nowprice = 0;
Else
$nowprice = $allprice/$sum;
$x = ($hu [$i][2]-34100)/10;
$y =-$nowprice *0.5+110;
if ($i ==0)
{
$x 1= $x;
$y 1= $y;
}
Else
{
Imageline ($im, $x 1, $y 1, $x, $y 1, $linecolor 1);
Imageline ($im, $x, $y 1, $x, $y, $linecolor 1);
$x 1= $x;
$y 1= $y;
}
}
Imageline ($im, $x 1, $y 1,570, $y 1, $linecolor 1);
Draw End
Picture explanation section begins *******************//
$str 0=iconv ("GB2312", "UTF-8", $str);
$str 1=iconv ("GB2312", "UTF-8", "The red line on the map of the settlement price lines, Purple Line for the price curve, the following figure red line means volume, blue lines to express total volume");
Imagettftext ($im, 10,0,30,240, $linecolor 1, "D:/winnt/fonts/simhei.ttf", $str 0);
Imagettftext ($im, 10,0,30,255, $linecolor 1, "D:/winnt/fonts/simhei.ttf", $str 1);
Picture explanation section ends *******************//
Imagegif ($im);
Imagedestroy ($im);
}
Else
{
The time starts from 2005-05-24
Print "<form action=index.php method=post>
<input Type=hidden Name=go value=1>
Select the time:
<select name=time> ";
For ($i =0 $i <100; $i + +)
{
$time 1=date ("Y-n-j", Mktime (0,0,0,date ("M"), Date ("D")-$i, date ("Y")));
$time 2=date ("y-m-d", Mktime (0,0,0,date ("M"), Date ("D")-$i, date ("Y")));
if (Is_dir ($time 1))
Print "<option value=\" $time 1\ "> $time 2</option>
";
}
Print "</select>
<p>
<input type=submit Name=submit value= Submit >
</form> ";
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.