Kod
$a=new Date();
$a->date1="6-20-2008";
$a->date2="9-1-2008";
$s=$a->days();
$a->date1="6-20-2008";
$a->date2=date("m-d-Y");
$f=$a->days();
$procent=round(($f/$s)*100,1 );
$new=ImageCreate(600,50);
$col=imagecolorallocate($new,0,0,0);
ImageFill($new, 600, 50, $col);
$col21=imagecolorallocate($new,64,150,238);
ImageRectangle($new, 3, 10, 503, 40, $col21);
if($procent==0){
}else{
$col2=imagecolorallocate($new,180,180,180);
$liczproc=500*($procent/100);
ImageFilledRectangle($new, 3, 10, $liczproc, 40, $col2);
}
$col22=imagecolorallocate($new,180,180,180);
ImageFilledRectangle($new, 505, 8, 570, 42, $col22);
$textcolor=imagecolorallocate($new,0,0,0);
$string = iconv("Windows-1250", "Latin2", $procent."%");
ImageString($new, 6, 515, 17, $string , $textcolor);
header("Content-type: image/png");
ImagePng($new);
imagedestroy($new);
$a->date1="6-20-2008";
$a->date2="9-1-2008";
$s=$a->days();
$a->date1="6-20-2008";
$a->date2=date("m-d-Y");
$f=$a->days();
$procent=round(($f/$s)*100,1 );
$new=ImageCreate(600,50);
$col=imagecolorallocate($new,0,0,0);
ImageFill($new, 600, 50, $col);
$col21=imagecolorallocate($new,64,150,238);
ImageRectangle($new, 3, 10, 503, 40, $col21);
if($procent==0){
}else{
$col2=imagecolorallocate($new,180,180,180);
$liczproc=500*($procent/100);
ImageFilledRectangle($new, 3, 10, $liczproc, 40, $col2);
}
$col22=imagecolorallocate($new,180,180,180);
ImageFilledRectangle($new, 505, 8, 570, 42, $col22);
$textcolor=imagecolorallocate($new,0,0,0);
$string = iconv("Windows-1250", "Latin2", $procent."%");
ImageString($new, 6, 515, 17, $string , $textcolor);
header("Content-type: image/png");
ImagePng($new);
imagedestroy($new);
Ale stwierdziłem że wygląda beznadziejnie . Więc zrobiłem wersje bardziej przyjazną dla oka :
Kod
$a=new Date();
$a->date1="6-20-2008";
$a->date2="9-1-2008";
$s=$a->days();
$a->date1="6-20-2008";
$a->date2=date("m-d-Y");
$f=$a->days();
$procenta=($f/$s)*100;
$procent=round(($f/$s)*100,1 );
$imagename="tlo.jpg";
$image=imagecreatefromjpeg($imagename);
$col21=imagecolorallocate($image,64,150,238);
ImageRectangle($image, 16, 110, 503, 90, $col21);
if($procent!=0){
$col2=imagecolorallocate($image,180,180,180);
$liczproc=500*($procenta/100);
imagefilledrectangle($image, 16, 110, $liczproc, 90, $col2); // tu jest niedziałający pasek
!
}else{
}
$textcolor=imagecolorallocate($image,255,255,255);
$string = iconv("Windows-1250", "Latin2", $procent."%");
ImageString($image, 60, 531, 93, $string , $textcolor);
$string1 = iconv("Windows-1250", "Latin2", "Liczba dni w roku szkolnym: ".$s);
ImageString($image,5, 10, 130, $string1 , $textcolor);
$string1 = iconv("Windows-1250", "Latin2", "Liczba dni która już upłynęła: ".$f);
ImageString($image,5, 10, 160, $string1 , $textcolor);
$string1 = iconv("Windows-1250", "Latin2", "Jaki to procent wszystkich dni: ".round($procenta,3)."%");
ImageString($image,5, 10, 190, $string1 , $textcolor);
header("Content-type: image/jpg");
imagejpeg($image);
imagedestroy($image);
$a->date1="6-20-2008";
$a->date2="9-1-2008";
$s=$a->days();
$a->date1="6-20-2008";
$a->date2=date("m-d-Y");
$f=$a->days();
$procenta=($f/$s)*100;
$procent=round(($f/$s)*100,1 );
$imagename="tlo.jpg";
$image=imagecreatefromjpeg($imagename);
$col21=imagecolorallocate($image,64,150,238);
ImageRectangle($image, 16, 110, 503, 90, $col21);
if($procent!=0){
$col2=imagecolorallocate($image,180,180,180);
$liczproc=500*($procenta/100);
imagefilledrectangle($image, 16, 110, $liczproc, 90, $col2); // tu jest niedziałający pasek

}else{
}
$textcolor=imagecolorallocate($image,255,255,255);
$string = iconv("Windows-1250", "Latin2", $procent."%");
ImageString($image, 60, 531, 93, $string , $textcolor);
$string1 = iconv("Windows-1250", "Latin2", "Liczba dni w roku szkolnym: ".$s);
ImageString($image,5, 10, 130, $string1 , $textcolor);
$string1 = iconv("Windows-1250", "Latin2", "Liczba dni która już upłynęła: ".$f);
ImageString($image,5, 10, 160, $string1 , $textcolor);
$string1 = iconv("Windows-1250", "Latin2", "Jaki to procent wszystkich dni: ".round($procenta,3)."%");
ImageString($image,5, 10, 190, $string1 , $textcolor);
header("Content-type: image/jpg");
imagejpeg($image);
imagedestroy($image);
I coś zaczyna nie grać bo na localhost działają obydwie wersje skryptu a na serwerze tylko ta pierwsza . Druga wygląda tak: http://www.lo1.hekko.pl/licznik/date2.php - całkowicie brak paska postępu (imagefilledrectangle()).
wersja GD na localhost :bundled (2.0.34 compatible)
wersja na serwerze: 2.0 or higher(?)
Co mogę zrobić żeby działało?