(time() - $expire)) ) { $itable = file_get_contents($file); } else { $itable=''; $query="select max(date) as maxdate from indexval"; $result=mysql_query($query); if (mysql_num_rows($result) > 0) { if($row = mysql_fetch_assoc ($result)) { $indexdate=$row['maxdate']; } } mysql_free_result($result); //logme("indexdate = ".$indexdate); $Hnow=date("H"); $newidate=""; $sofixVal = 0; $sofixPerc = 0; $bg40Val = 0; $bg40Perc = 0; $bgreitVal = 0; $bgreitPerc = 0; $bgtr30Val = 0; $bgtr30Perc = 0; if($Hnow>"08" && $Hnow<"23" && $indexdate"; $itable .= "".$sofixPerc."%"; $itable .= ""; $itable .= "BGBX40"; $itable .= "".$bg40Val.""; $itable .= "".$bg40Perc."%"; $itable .= ""; $itable .= "BGREIT"; $itable .= "".$bgreitVal.""; $itable .= "".$bgreitPerc."%"; $itable .= ""; $itable .= "BGTR30"; $itable .= "".$bgtr30Val.""; $itable .= "".$bgtr30Perc."%"; $itable .= ""; } //logme("newidate = ".$newidate); if($newidate>$indexdate && $Hnow>="18"){ $query="insert into indexval (date,indexid,value,chproc) VALUES ('".$newidate."',1,".$sofixVal.",".$sofixPerc.")"; //logme("sql = ".$query); mysql_query($query); $query="insert into indexval (date,indexid,value,chproc) VALUES ('".$newidate."',2,".$bg40Val.",".$bg40Perc.")"; //logme("sql = ".$query); mysql_query($query); $query="insert into indexval (date,indexid,value,chproc) VALUES ('".$newidate."',3,".$bgreitVal.",".$bgreitPerc.")"; //logme("sql = ".$query); mysql_query($query); $query="insert into indexval (date,indexid,value,chproc) VALUES ('".$newidate."',4,".$bgtr30Val.",".$bgtr30Perc.")"; //logme("sql = ".$query); mysql_query($query); } if(strlen($itable)==0) { $query="select id,title,value,chproc from indexes left outer join indexval on (id=indexid and date='".$indexdate."') order by id"; $result=mysql_query($query); if (mysql_num_rows($result) > 0) { while($row = mysql_fetch_assoc ($result)) { $itable .= "".$row['title'].""; $itable .= "".$row['value'].""; $itable .= "0?"p":"m")."'>".$row['chproc']."%"; $itable .= ""; } } mysql_free_result($result); } //Hnow $fp = fopen($file,"w"); fputs($fp, $itable); fclose($fp); } echo $itable; } function DrawChart($cindexid=1, $period=1) { $cvals = array(); $cdates = array(); $min = -1; $max = -1; //logme("cind=".$cindexid.";period=".$period); if ($period==3) { $csteps = 2; $date_start = date("Y-m-d",strtotime("-1 week")); } elseif ($period==2) { $csteps = 5; $date_start = date("Y-m-d",strtotime("-1 month")); } elseif ($period==4) { $csteps = 90; $date_start = date("Y-m-d",strtotime("-36 months")); } elseif ($period==5) { $csteps = 150; $date_start = date("Y-m-d",strtotime("-60 months")); } elseif ($period==6) { $csteps = 30; $date_start = date("Y-m-d",strtotime("-6 months")); } else { $csteps = 30; $date_start = date("Y-m-d",strtotime("-12 months")); } if ($cindexid==1) { $ititle='SOFIX'; } elseif ($cindexid==2) { $ititle='BGBX40'; } elseif ($cindexid==4) { $ititle='BGTR30'; } elseif ($cindexid==3) { $ititle='BGREIT'; } else { $ititle='N/A'; } $file = 'cache/cache_ps.'.$cindexid.'.'.$period; $expire = 1800; if (file_exists($file) && (filemtime($file) > (time() - $expire)) ) { $PrettyS = file_get_contents($file); } else { $query="select date,value from indexval where indexid=".$cindexid." and date>'" . $date_start . "' order by date "; $result=mysql_query($query); if (mysql_num_rows($result) > 0) { while($row = mysql_fetch_assoc ($result)) { $cdates[] = substr($row['date'],8,2).".".substr($row['date'],5,2); $dl = substr($row['date'],8,2).".".substr($row['date'],5,2).".".substr($row['date'],2,2); $cval = floatval($row['value']); $d = new dot($cval); //$cvals[] = $cval; $cvals[] = $d->tooltip($dl."
#val#"); if ($min==-1) { $min=$cval; $max=$cval; } else { if ($min>$cval) $min=$cval; if ($max<$cval) $max=$cval; } } } else { $cdates[] = "N/A"; $cvals[] = 0; } mysql_free_result($result); $title = new title( $ititle ); $title->set_style( "{font-size: 10px; color: #000000; text-align: center;}" ); $line = new line(); $line->set_values( $cvals); //$line->set_colour( '#A2ACBA' ); $line->set_colour( '#000000' ); //$line->set_tooltip("Value: #val#"); //$line->set_title_style( "{font-size: 10px;" ); $chart = new open_flash_chart(); $chart->set_bg_colour( '#D3D3D3' ); $chart->set_title( $title ); $chart->add_element( $line ); $y = new y_axis(); //$y->set_colours( '#A2ACBA','#A2ACBA' ); $y->set_colours( '#000000','#000000' ); $xstep= intval(($max-$min)/4); if($xstep<2) $xstep=2; $y->set_range(intval($min-1),intval($max+1),$xstep); $chart->set_y_axis($y); $x = new x_axis(); $x->set_steps( $csteps ); $x->set_grid_colour('#000000'); $x_labels = new x_axis_labels(); $x_labels->set_steps( $csteps ); $x_labels->set_vertical(); //$x_labels->rotate(-25); $x_labels->set_labels( $cdates); $x_labels->set_size(8); $x_labels->set_colour( '#000000' ); $x->set_labels( $x_labels ); $chart->set_x_axis($x); $PrettyS=$chart->toPrettyString(); // $fp = fopen($file,"w"); fputs($fp, $PrettyS); fclose($fp); } return $PrettyS; } ?> Real Finance: Клиенти Text to send if user hits Cancel button