Birthday banner script

Hi,

Many years ago I created a script (combining a few other scripts) to show the birthday of my doughter on a image.
I haven’t used the script for years and wanted to use it again but It doesn’t work anymore.

I don’t have the skills to figure out what is wrong with the script and hope someone can help me to fix it.

<?php   

ini_set(‘display_errors’, 1);
ini_set(‘display_startup_errors’, 1);
error_reporting(E_ALL);

//Naam child
$child = “name child”;

//birthdate
$basic_day = 21;
$basic_month = 11;
$basic_year = 2016;

//date script
$current_day = date (“j”);
$current_month = date (“n”);
$current_year = date (“Y”);

$basic_month_max = date (“t”,mktime (0,0,0,$basic_month,$basic_day,$basic_year));

$basic_day_diff = $basic_month_max - $basic_day;

$basic_month_diff = 12 - $basic_month - 1;

$start_day = 1;
$start_month = 1;
$start_year = $basic_year + 1;

$day_difference = ($current_day - $start_day) + 1;
$month_difference = ($current_month - $start_month) + 1;
$year_difference = ($current_year - $start_year);

$day_difference = $day_difference + $basic_day_diff;
$month_difference = $month_difference + $basic_month_diff;

if ($day_difference >= $basic_month_max)
{
$day_difference = $day_difference - $basic_month_max;
$month_difference = $month_difference + 1;
}

if ($month_difference >= 12)
{
$month_difference = $month_difference - 12;
$year_difference = $year_difference + 1;
}

//watermarkdate

if ($month_difference == “0”) $monthposition = “12”;
if ($month_difference == “1”) $monthposition = “51”;
if ($month_difference == “2”) $monthposition = “90”;
if ($month_difference == “3”) $monthposition = “129”;
if ($month_difference == “4”) $monthposition = “168”;
if ($month_difference == “5”) $monthposition = “206”;
if ($month_difference == “6”) $monthposition = “245”;
if ($month_difference == “7”) $monthposition = “284”;
if ($month_difference == “8”) $monthposition = “325”;
if ($month_difference == “9”) $monthposition = “365”;
if ($month_difference == “10”) $monthposition = “406”;
if ($month_difference == “11”) $monthposition = “441”;

// watermarkdate

// images script

//text view
If($day_difference === 1 AND $month_difference === 1)
{
$text = “$child is $year_difference year, $month_difference month en $day_difference day”;
}
else
If($day_difference === 1 AND $month_difference !== 1)
{
$text = “$child is $year_difference year, $month_difference months en $day_difference day”;
}
else
If($day_difference !== 1 AND $month_difference === 1)
{
$text = “$child is $year_difference year, $month_difference month en $day_difference days”;
}
else
If($day_difference !== 1 AND $month_difference !== 1)
{
$text = “$child is $year_difference year, $month_difference months en $day_difference days”;
}
//end text view

// Choose backgroundimage

$imagesfile=“images/background”.$year_difference.".gif";

// End choose backgroundimage

$extension=substr($imagesfile,-3);
$extension=strtolower($extension);

if($extension==“gif”)
{
header(“Content-type: image/gif”);
imagegif($image);
}

else

if($extension==“png”)
{
header(“Content-type: image/png”);
imagepng($image);
}
else
{
header(“Content-type: image/jpeg”);
imagejpeg($image);
}

// Choose lettertype
$lettertype = ‘JacciCharcoalPrint Regular.ttf’;
// End choose lettertype

if($extension==“jpg” || $extension==“jpe”) $image=imagecreatefromjpeg("$imagesfile");
else
if ($extension==“gif”) $image=imagecreatefromgif("$imagesfile");
else
if ($extension==“png”) $image=imagecreatefrompng("$imagesfile");
else
{print “unknown image format”; exit;}

if (!$image) { /* show when failure /
$image = ImageCreate (150, 30); /
make an empty image /
$backgroundcolor = ImageColorAllocate ($image, 255, 255, 255);
$tc = ImageColorAllocate ($image, 0, 0, 0);
ImageFilledRectangle ($image, 0, 0, 150, 30, $backgroundcolor);
/
error */
ImageString($image, 1, 5, 5, “error while loading $imagesfile”, $tc);
return $image;
}

$x=imagesx($image);
$y=imagesy($image);
$lettertypesize=$x/23;
$lettertypesize=floor($lettertypesize);
if($lettertypesize<10) $lettertypesize=10;

// lettertype color
$black = imagecolorallocate($image, 0, 0, 0);
$white = imagecolorallocate($image, 255, 255, 255);

imagettftext($image, $lettertypesize, 0, 10, $lettertypesize+6, $black, $lettertype, $text);

// Choose monthposition image (watermark)

$insert = imagecreatefromgif(“images/nijntje”.$year_difference.".gif");

// End choose monthposition image (watermark)

imagecolortransparent($insert,imagecolorexact($insert,255,0,255));

$horizontal = imagesx($insert);
$vertical = imagesy($insert);

imagecopymerge($image,$insert,$monthposition,27,0,0,$horizontal,$vertical,100);

imagegif($image,"",100);

imagedetroy($image);

?>

Sponsor our Newsletter | Privacy Policy | Terms of Service