1 |
dpavlin |
1.1 |
<?php |
2 |
|
|
|
3 |
|
|
require("dbi_pgsql.php"); |
4 |
|
|
|
5 |
|
|
$dbh = new DBI("corp","dpavlin",""); |
6 |
|
|
$sth=$dbh->prepare("set datestyle='german'"); |
7 |
|
|
$sth->execute(); |
8 |
|
|
|
9 |
|
|
$type='LSE'; |
10 |
|
|
|
11 |
|
|
$sql="select date(date) as date,time(date) as time,stocks.type as type,current,change,high,low,open from stocks where stocks.type='$type' order by stocks.date desc limit 1"; |
12 |
|
|
|
13 |
|
|
$sth = $dbh->prepare("$sql"); |
14 |
|
|
$sth->execute(); |
15 |
|
|
if ($row=$sth->fetchrow_hash()) { |
16 |
|
|
$time=$row[time]; |
17 |
|
|
} |
18 |
|
|
|
19 |
|
|
if ($time == "23:23:23" || $time == "21:21:21" || $time == "22:21:21" ) $time="CLOSE"; |
20 |
|
|
|
21 |
|
|
#Header("Content-type: image/gif"); |
22 |
|
|
Header("Content-type: image/png"); |
23 |
dpavlin |
1.2 |
Header("Expires: ".gmdate("D, d M Y H:i:s",time()+(5*60))." GMT"); |
24 |
|
|
$im = imagecreate(350,30); |
25 |
dpavlin |
1.1 |
$black = ImageColorAllocate($im, 0,0,0); |
26 |
|
|
$white = ImageColorAllocate($im, 255,255,255); |
27 |
dpavlin |
1.2 |
//$white = ImageColorAllocate($im, 180,180,255); // debug |
28 |
|
|
ImageFill($im,0,0,$white); |
29 |
|
|
$text=sprintf("%s at %s current %.2f\n\rchange: %.2f high: %.2f low: %.2f open: %.2f",$row[date],$time,$row[current],$row[change],$row[high],$row[low],$row[open]); |
30 |
|
|
ImageTTFText($im, 10, 0, 00, 10, $black, "verdanab.ttf",$text); |
31 |
dpavlin |
1.1 |
#ImageGif($im); |
32 |
|
|
ImagePng($im); |
33 |
|
|
ImageDestroy($im); |
34 |
|
|
?> |