Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php # INTERACTIVE STICKER for WU # based on Stickers plugin for Meteotemplate # ht..
Decoded Output download
<?php
# INTERACTIVE STICKER for WU
# based on Stickers plugin for Meteotemplate
# http://www.meteotemplate.com
# Author: Jachym
# [email protected]
# Meteotemplate 2016
# License: free to use, Meteotemplate logo and text in bottom right corner must be left untouched
#####################################################################################################################
# SETTINGS
#
# see readme file for instructions how to use!
#####################################################################################################################
$stationTZ = "Europe/Prague"; // specify your timezone (see http://php.net/manual/en/timezones.php)
$stationCountry = "cz"; // lowercase two-letter ISO code of your country
$stationLat = 49.2; // your station latitude (in decimal numbers, negative for Southern hemisphere)
$stationLon = 16.4; // your station longitude (in decimal numbers, negative for Western hemisphere)
$timeFormat = "H:i"; // see PHP date formats
$dateFormat = "d-m-Y";
$pageURL = "http://www.meteotemplate.com"; // URL of your website
$WUID = "IJIHOMOR28";
$pressureUnits = "hPa"; // inHg or hPa
$rainUnits = "mm"; // in or mm
$temperatureUnits = "C"; // C or F
$windUnits = "km/h"; // mph, km/h or m/s
#####################################################################################################################
#
# DO NOT EDIT BELOW!!!
#
#####################################################################################################################
header('Content-type: image/png');
date_default_timezone_set($stationTZ);
$url = 'https://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID='.$WUID.'&month='.date("n").'&year='.date("Y").'&day='.date("j").'&format=1';
$rawData = file_get_contents($url);
if($rawData==""){
$rawData = curlMain($url,5);
}
$data = explode("<br>",trim($rawData));
$data = array_filter($data);
// get header
$header = explode(",",$data[0]);
for($i=0;$i<count($header);$i++){
$identify = getFields($header[$i],$i);
if($identify[0]!=""){
$parameters[$identify[0]] = $i;
$units[$identify[0]] = $identify[1];
}
}
if(count($data)>1){
$latestRow = explode(",",$data[(count($data)-1)]);
}
if(isset($latestRow[$parameters['T']])){
if($units['T']=="C" && $temperatureUnits=="F"){
$Traw = convertor($latestRow[$parameters['T']],"C","F");
$T = number_format($Traw,1,".","");
}
else if($units['T']=="F" && $temperatureUnits=="C"){
$Traw = convertor($latestRow[$parameters['T']],"F","C");
$T = number_format($Traw,1,".","");
}
else{
$T = number_format($latestRow[$parameters['T']],1,".","");
}
}
else{
$T = "-";
}
if(isset($latestRow[$parameters['W']])){
if($units['W']=="km/h" && $windUnits=="m/s"){
$Wraw = convertor($latestRow[$parameters['W']],"kmh","ms");
$W = number_format($Wraw,1,".","");
}
else if($units['W']=="km/h" && $windUnits=="mph"){
$Wraw = convertor($latestRow[$parameters['W']],"kmh","mph");
$W = number_format($Wraw,1,".","");
}
else if($units['W']=="m/s" && $windUnits=="km/h"){
$Wraw = convertor($latestRow[$parameters['W']],"ms","kmh");
$W = number_format($Wraw,1,".","");
}
else if($units['W']=="m/s" && $windUnits=="mph"){
$Wraw = convertor($latestRow[$parameters['W']],"ms","mph");
$W = number_format($Wraw,1,".","");
}
else if($units['W']=="mph" && $windUnits=="km/h"){
$Wraw = convertor($latestRow[$parameters['W']],"mph","kmh");
$W = number_format($Wraw,1,".","");
}
else if($units['W']=="mph" && $windUnits=="m/s"){
$Wraw = convertor($latestRow[$parameters['W']],"mph","ms");
$W = number_format($Wraw,1,".","");
}
else{
$W = number_format($latestRow[$parameters['W']],1,".","");
}
}
else{
$W = "-";
}
if(isset($latestRow[$parameters['H']])){
$H = number_format($latestRow[$parameters['H']],1,".","");
}
else{
$H = "-";
}
if(isset($latestRow[$parameters['P']])){
$currentP = $latestRow[$parameters['P']]; // for trend calculation
if($units['P']=="hPa" && $pressureUnits=="inHg"){
$Praw = convertor($latestRow[$parameters['P']],"hpa","inhg");
$P = number_format($Praw,2,".","");
}
else if($units['P']=="inHg" && $pressureUnits=="hPa"){
$Praw = convertor($latestRow[$parameters['P']],"inhg","hpa");
$P = number_format($Praw,1,".","");
}
else{
if($units['P']=="hPa"){
$P = number_format($latestRow[$parameters['P']],1,".","");
}
else{
$P = number_format($latestRow[$parameters['P']],2,".","");
}
}
}
else{
$P = "-";
}
if(isset($latestRow[$parameters['R']])){
if($units['R']=="mm" && $rainUnits=="in"){
$Rraw = convertor($latestRow[$parameters['R']],"mm","in");
$R = number_format($Rraw,2,".","");
}
else if($units['R']=="in" && $rainUnits=="mm"){
$Rraw = convertor($latestRow[$parameters['R']],"in","mm");
$R = number_format($Rraw,1,".","");
}
else{
if($units['R']=="mm"){
$R = number_format($latestRow[$parameters['R']],1,".","");
}
else{
$R = number_format($latestRow[$parameters['R']],2,".","");
}
}
}
else{
$R = "-";
}
if(isset($latestRow[0])){
$currentTime = strtotime($latestRow[0]);
}
else{
$currentTime = time();
}
if(isset($data[count($data)-2][$parameters['P']])){
$previousP = $data[count($data)-2][$parameters['P']];
$trendP = $currentP - $previousP;
}
else{
$trendP = 0;
}
for($i=1;$i<count($data);$i++){
$thisrow = explode(",",$data[$i]);
if($units['T']=="C" && $temperatureUnits=="F"){
$Traw = convertor($thisrow[$parameters['T']],"C","F");
$Traw = number_format($Traw,1,".","");
}
else if($units['T']=="F" && $temperatureUnits=="C"){
$Traw = convertor($thisrow[$parameters['T']],"F","C");
$Traw = number_format($Traw,1,".","");
}
else{
$Traw = number_format($thisrow[$parameters['T']],1,".","");
}
if($units['W']=="km/h" && $windUnits=="m/s"){
$Wraw = convertor($latestRow[$parameters['G']],"kmh","ms");
$G = number_format($Wraw,1,".","");
}
else if($units['W']=="km/h" && $windUnits=="mph"){
$Wraw = convertor($latestRow[$parameters['G']],"kmh","mph");
$G = number_format($Wraw,1,".","");
}
else if($units['W']=="m/s" && $windUnits=="km/h"){
$Wraw = convertor($latestRow[$parameters['G']],"ms","kmh");
$G = number_format($Wraw,1,".","");
}
else if($units['W']=="m/s" && $windUnits=="mph"){
$Wraw = convertor($latestRow[$parameters['G']],"ms","mph");
$G = number_format($Wraw,1,".","");
}
else if($units['W']=="mph" && $windUnits=="km/h"){
$Wraw = convertor($latestRow[$parameters['G']],"mph","kmh");
$G = number_format($Wraw,1,".","");
}
else if($units['W']=="mph" && $windUnits=="m/s"){
$Wraw = convertor($latestRow[$parameters['G']],"mph","ms");
$G = number_format($Wraw,1,".","");
}
else{
$G = number_format($latestRow[$parameters['G']],1,".","");
}
$temperatures[] = $Traw;
$humidities[] = $thisrow[$parameters['H']];
$gusts[] = $G;
}
if(count($temperatures)>0){
$dailyMinT = number_format(min($temperatures),1,".","");
$dailyMaxT = number_format(max($temperatures),1,".","");
}
else{
$dailyMinT = "-";
$dailyMaxT = "-";
}
if(count($humidities)>0){
$dailyMinH = number_format(min($humidities),1,".","");
$dailyMaxH = number_format(max($humidities),1,".","");
}
else{
$dailyMinH = "-";
$dailyMaxH = "-";
}
if(count($gusts)>0){
$dailyMaxG = number_format(max($gusts),1,".","");
}
else{
$dailyMaxG = "-";
}
function getFields($parameter,$field){
$parameter = trim(strtolower($parameter));
$paramID = "";
$units = "";
$number = "";
if($parameter=="temperaturec"){
$paramID = 'T';
$units = "C";
$number = $field;
}
if($parameter=="temperaturef"){
$paramID = 'T';
$units = "F";
$number = $field;
}
if($parameter=="pressurehpa"){
$paramID = 'P';
$units = "hPa";
$number = $field;
}
if($parameter=="pressurein"){
$paramID = 'P';
$units = "inHg";
$number = $field;
}
if($parameter=="windspeedkmh"){
$paramID = 'W';
$units = "km/h";
$number = $field;
}
if($parameter=="windspeedmph"){
$paramID = 'W';
$units = "mph";
$number = $field;
}
if($parameter=="windspeedmps"){
$paramID = 'W';
$units = "m/s";
$number = $field;
}
if($parameter=="windspeedms"){
$paramID = 'W';
$units = "m/s";
$number = $field;
}
if($parameter=="windspeedgustkmh"){
$paramID = 'G';
$units = "km/h";
$number = $field;
}
if($parameter=="windspeedgustmph"){
$paramID = 'G';
$units = "mph";
$number = $field;
}
if($parameter=="windspeedgustmps"){
$paramID = 'G';
$units = "m/s";
$number = $field;
}
if($parameter=="windspeedgustms"){
$paramID = 'G';
$units = "m/s";
$number = $field;
}
if($parameter=="humidity"){
$paramID = 'H';
$units = "%";
$number = $field;
}
if($parameter=="dailyrainmm"){
$paramID = 'R';
$units = "mm";
$number = $field;
}
if($parameter=="dailyrainin"){
$paramID = 'R';
$units = "in";
$number = $field;
}
return array($paramID,$units,$number);
}
function curlMain($url,$timeout){
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows NT 6.1; rv:19.0) Gecko/20100101 Firefox/19.0");
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
function convertor($n,$unit1,$unit2){
// prepare input
$unit1 = trim(strtolower($unit1));
$unit2 = trim(strtolower($unit2));
$unit1 = str_replace("/","",$unit1);
$unit2 = str_replace("/","",$unit2);
$unit1 = str_replace("kts","kt",$unit1);
$unit2 = str_replace("kts","kt",$unit2);
$unit1 = str_replace("knots","kt",$unit1);
$unit2 = str_replace("knots","kt",$unit2);
$unit1 = str_replace("kph","kmh",$unit1);
$unit2 = str_replace("kph","kmh",$unit2);
$unit1 = str_replace("mb","hpa",$unit1);
$unit2 = str_replace("mb","hpa",$unit2);
$unit1 = str_replace("miles","mi",$unit1);
$unit2 = str_replace("miles","mi",$unit2);
$unit1 = str_replace("feet","ft",$unit1);
$unit2 = str_replace("feet","ft",$unit2);
$unit1 = str_replace("foot","ft",$unit1);
$unit2 = str_replace("foot","ft",$unit2);
// return same units
if($unit1==$unit2){
return $n;
}
// temperature
else if($unit1=="c" && $unit2=="f"){
return $n*1.8 + 32;
}
else if($unit1=="f" && $unit2=="c"){
return ($n - 32)/1.8;
}
// wind speed
else if($unit1=="ms" && $unit2=="kmh"){
return $n * 3.6;
}
else if($unit1=="ms" && $unit2=="mph"){
return $n * 2.23694;
}
else if($unit1=="ms" && $unit2=="kt"){
return $n * 1.943844;
}
else if($unit1=="kmh" && $unit2=="ms"){
return $n / 3.6;
}
else if($unit1=="kmh" && $unit2=="mph"){
return $n * 0.621371;
}
else if($unit1=="kmh" && $unit2=="kt"){
return $n * 0.539957;
}
else if($unit1=="mph" && $unit2=="ms"){
return $n * 0.44704;
}
else if($unit1=="mph" && $unit2=="kmh"){
return $n * 1.609344;
}
else if($unit1=="mph" && $unit2=="kt"){
return $n * 0.868976;
}
else if($unit1=="kt" && $unit2=="ms"){
return $n * 0.514444;
}
else if($unit1=="kt" && $unit2=="kmh"){
return $n * 1.852;
}
else if($unit1=="kt" && $unit2=="mph"){
return $n * 1.150779;
}
// pressure
else if($unit1=="hpa" && $unit2=="inhg"){
return $n * 0.02952998;
}
else if($unit1=="hpa" && $unit2=="mmhg"){
return $n * 0.750063755;
}
else if($unit1=="inhg" && $unit2=="hpa"){
return $n * 33.863881;
}
else if($unit1=="inhg" && $unit2=="mmhg"){
return $n * 25.400069;
}
else if($unit1=="mmhg" && $unit2=="hpa"){
return $n * 1.3332239;
}
else if($unit1=="mmhg" && $unit2=="inhg"){
return $n * 0.03937;
}
// precipitation
else if($unit1=="mm" && $unit2=="in"){
return $n * 0.0393701;
}
else if($unit1=="in" && $unit2=="mm"){
return $n * 25.4;
}
// distance
else if($unit1=="km" && $unit2=="mi"){
return $n * 0.621371;
}
else if($unit1=="mi" && $unit2=="km"){
return $n * 1.60934;
}
else if($unit1=="km" && $unit2=="ft"){
return $n * 3280.84;
}
else if($unit1=="ft" && $unit2=="km"){
return $n * 0.0003048;
}
else if($unit1=="m" && $unit2=="ft"){
return $n * 3.28084;
}
else if($unit1=="ft" && $unit2=="m"){
return $n * 0.3048;
}
}
// apply conversions
$displayTempUnits = $temperatureUnits;
$displayPressUnits = $pressureUnits;
$displayRainUnits = $rainUnits;
$displayWindUnits = $windUnits;
$time = date($timeFormat,$currentTime);
$date = date($dateFormat,$currentTime);
$stationTimezone = new DateTimeZone($stationTZ);
$stationOffset = $stationTimezone->getOffset(new DateTime)/3600;
// get sunrise and sunset times
$sunRiseTS = date_sunrise(time(),SUNFUNCS_RET_TIMESTAMP,$stationLat,$stationLon,90.5);
$sunSetTS = date_sunset(time(),SUNFUNCS_RET_TIMESTAMP,$stationLat,$stationLon,90.5);
// current time
$currentTime = time();
// before sunrise
if($currentTime<($sunRiseTS-30*60)){
$dayTime = "night";
}
// after sunset
else if($currentTime>($sunSetTS+30*60)){
$dayTime = "night";
}
// hour within sunrise
else if($currentTime>=($sunRiseTS-30*60) && $currentTime<=($sunRiseTS+30*60)){
$dayTime = "sunrise";
}
// hour within sunset
else if($currentTime>=($sunSetTS-30*60) && $currentTime<=($sunSetTS+30*60)){
$dayTime = "sunset";
}
// else must be day
else{
$dayTime = "day";
}
// get parameters
if(isset($_GET['text'])){
$text = $_GET['text'];
}
else{
$text = "Meteotemplate";
}
if(isset($_GET['font'])){
$fontFace = "fonts/".$_GET['font'].".ttf";
}
else{
$fontFace = "fonts/Ubuntu-Regular.ttf";
}
if(isset($_GET['bg'])){
$bgURL = 'bgs/'.$_GET['bg'].'.jpg';
$bgNumber = $_GET['bg'];
}
else{
$bgURL = 'bgs/10.jpg';
$bgNumber = 10;
}
if(isset($_GET['border'])){
$border = $_GET['border'];
}
else{
$border = 5;
}
if(isset($_GET['bgColor'])){
$bgColor = hex2rgb($_GET['bgColor']);
}
else{
$bgColor = hex2rgb('000');
}
if(isset($_GET['shadow'])){
if($_GET['shadow']==0){
$shadow = false;
}
else{
$shadow = true;
}
}
else{
$shadow = false;
}
if(isset($_GET['color'])){
$stickerColor = $_GET['color'];
}
else{
$stickerColor = "white";
}
if($stickerColor=="white"){
$shadowColor = "black";
}
else{
$shadowColor = "white";
}
if($stickerColor=="black"){
if($trendP>0){
$imageP = "trendUpBlack.png";
}
if($trendP==0){
$imageP = "trendNeutralBlack.png";
}
if($trendP<0){
$imageP = "trendDownBlack.png";
}
}
else{
if($trendP>0){
$imageP = "trendUp.png";
}
if($trendP==0){
$imageP = "trendNeutral.png";
}
if($trendP<0){
$imageP = "trendDown.png";
}
}
// get type
if(isset($_GET['type'])){
if($_GET['type']=="random"){
$bgImagesAvailable = array_filter(glob('bgs/*.jpg'));
foreach($bgImagesAvailable as $availableImage){
$bgNames [] = $availableImage;
}
$bgNumber = rand(0,(count($bgNames)-1));
$bgURL = $bgNames[$bgNumber];
$shadow = 1;
}
if($_GET['type']=="interactive"){
$shadow = 1;
if($dayTime=='night'){
$items = array(27,68,145,146,40,38);
$bgNumber = $items[array_rand($items)];
$bgURL = 'bgs/'.$bgNumber.'.jpg';
$stickerColor = 'white';
$shadowColor = 'black';
}
if($dayTime=='day'){
$items = array(13,139,140,141,171,172);
$bgNumber = $items[array_rand($items)];
$bgURL = 'bgs/'.$bgNumber.'.jpg';
$stickerColor = 'white';
$shadowColor = 'black';
}
if($dayTime=='sunrise'){
$items = array(17,51,16,142,151,152);
$bgNumber = $items[array_rand($items)];
$bgURL = 'bgs/'.$bgNumber.'.jpg';
$stickerColor = 'white';
$shadowColor = 'black';
}
if($dayTime=='sunset'){
$items = array(17,51,16,137,138,151,152,177);
$bgNumber = $items[array_rand($items)];
$bgURL = 'bgs/'.$bgNumber.'.jpg';
$stickerColor = 'white';
$shadowColor = 'black';
}
if($RR>0){
$items = array(65,143,144,150);
$bgNumber = $items[array_rand($items)];
$bgURL = 'bgs/'.$bgNumber.'.jpg';
$stickerColor = 'white';
$shadowColor = 'black';
}
if($S>800){
$items = array(23);
$bgNumber = $items[array_rand($items)];
$bgURL = 'bgs/'.$bgNumber.'.jpg';
$stickerColor = 'black';
$shadowColor = 'white';
}
}
}
$widthShift = 0;
if(isset($_GET['image'])){
if($_GET['image']!="random"){
$thumbNail = true;
$widthShift = 175;
$customImage = imagecreatefrompng('imgs/'.$_GET['image'].".png");
}
else if($_GET['image']=="random"){
$thumbNail = true;
$widthShift = 175;
$customImagesAvailable = array_filter(glob('imgs/*'));
foreach($customImagesAvailable as $availableCustomImage){
$customNames [] = $availableCustomImage;
}
$customImageNumber = rand(0,(count($customNames)-1));
$customImage = imagecreatefrompng($customImagesAvailable[$customImageNumber]);
}
else{
$thumbNail = false;
}
}
else{
$thumbNail = false;
}
$width = 800;
if($thumbNail){
$widthImage = $width + $widthShift;
}
else{
$widthImage = $width;
}
$height = 170;
$png_image = imagecreatetruecolor($widthImage, $height);
imagealphablending( $png_image, true );
imagesavealpha( $png_image, true );
$colorWhite = hex2rgb("#660000");
$white = imagecolorallocate($png_image, 255, 255, 255);
$black = imagecolorallocate($png_image, 0, 0, 0);
$bgColorFinal = imagecolorallocate($png_image, $bgColor[0], $bgColor[1], $bgColor[2]);
imagefill ( $png_image , 0 ,0 , $bgColorFinal );
if($stickerColor=="black"){
$mainColor = $black;
$shadowColor = $white;
}
else{
$mainColor = $white;
$shadowColor = $black;
}
$bgImage = imagecreatefromjpeg($bgURL);
imagecopy($png_image, $bgImage, $widthShift+$border, $border, 0, 0, (800-$border*2), (170-$border*2));
$icon1 = imagecreatefrompng('flags/'.$stationCountry.'.png');
imagealphablending( $icon1, true );
imagesavealpha( $icon1, true );
imagecopy($png_image, $icon1, 2+$widthShift, 2, 0, 0, 80, 80);
if($thumbNail){
imagealphablending($customImage, true );
imagesavealpha( $customImage, true );
imagecopy($png_image, $customImage, $border, $border, 0, 0, 170, 170-$border*2);
}
if(!$shadow){
if($stickerColor=="black"){
$icon2 = imagecreatefrompng('logoSmallBlack.png');
}
else{
$icon2 = imagecreatefrompng('logoSmall.png');
}
imagealphablending( $icon2, true );
imagesavealpha( $icon2, true );
imagecopy($png_image, $icon2, 748+$widthShift, 112, 0, 0, 50, 50);
}
else{
if($stickerColor=="black"){
$icon2 = imagecreatefrompng('logoSmallBlack.png');
$icon2shadow = imagecreatefrompng('logoSmall.png');
}
else{
$icon2 = imagecreatefrompng('logoSmall.png');
$icon2shadow = imagecreatefrompng('logoSmallBlack.png');
}
imagealphablending( $icon2shadow, true );
imagesavealpha( $icon2shadow, true );
imagecopy($png_image, $icon2shadow, 749+$widthShift, 113, 0, 0, 50, 50);
imagealphablending( $icon2, true );
imagesavealpha( $icon2, true );
imagecopy($png_image, $icon2, 748+$widthShift, 112, 0, 0, 50, 50);
}
$pressureIcon = imagecreatefrompng($imageP);
imagealphablending( $pressureIcon, true );
imagesavealpha( $pressureIcon, true );
imagecopy($png_image, $pressureIcon, ($width/6 * 3 - 15)+$widthShift, 96, 0, 0, 30, 30);
if(!$shadow){
if($stickerColor=="black"){
$stationIcon = imagecreatefrompng('stationBlack.png');
}
else{
$stationIcon = imagecreatefrompng('station.png');
}
imagealphablending( $stationIcon, true );
imagesavealpha( $stationIcon, true );
imagecopy($png_image, $stationIcon, 17+$widthShift, 100, 0, 0, 50, 50);
}
else{
if($stickerColor=="black"){
$stationIcon = imagecreatefrompng('stationBlack.png');
$stationIconShadow = imagecreatefrompng('station.png');
}
else{
$stationIcon = imagecreatefrompng('station.png');
$stationIconShadow = imagecreatefrompng('stationBlack.png');
}
imagealphablending( $stationIconShadow, true );
imagesavealpha( $stationIconShadow, true );
imagecopy($png_image, $stationIconShadow, 18+$widthShift, 101, 0, 0, 50, 50);
imagealphablending( $stationIcon, true );
imagesavealpha( $stationIcon, true );
imagecopy($png_image, $stationIcon, 17+$widthShift, 100, 0, 0, 50, 50);
}
$licVar = base64_decode("TWV0ZW90ZW1wbGF0ZQ==");
if(!$shadow){
textLeft($png_image,90+$widthShift, 36, $text, 7, 17, $mainColor, 0);
textCenter($png_image,762+$widthShift, 40, $time, 8, 11, $mainColor, 0);
textCenter($png_image,762+$widthShift, 22, $date, 8, 10, $mainColor, 0);
textCenter($png_image,($width/6 + 1)+$widthShift, 75, $T, 7, 22, $mainColor, 0);
textCenter($png_image,($width/6 * 2 + 1)+$widthShift, 75, $H, 7, 22, $mainColor, 0);
textCenter($png_image,($width/6 * 3 + 1)+$widthShift, 75, $P, 7, 22, $mainColor, 0);
textCenter($png_image,($width/6 * 4 + 1)+$widthShift, 75, $W, 7, 22, $mainColor, 0);
textCenter($png_image,($width/6 * 5 + 1)+$widthShift, 75, $R, 7, 22, $mainColor, 0);
textCenter($png_image,($width/6)+$widthShift, 96, ("TODAY"), 3, 8, $mainColor, 0);
textCenter($png_image,($width/6 * 2)+$widthShift, 96, ("%"), 5, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 3)+$widthShift, 96, ("3 H"), 3, 8, $mainColor, 0);
textCenter($png_image,($width/6 * 4)+$widthShift, 96, ("MAX TODAY"), 3, 8, $mainColor, 0);
textCenter($png_image,($width/6)+$widthShift, 117, ($dailyMaxT." / ".$dailyMinT), 5, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 2)+$widthShift, 117, ($dailyMaxH." / ".$dailyMinH), 5, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 4)+$widthShift, 117, ($dailyMaxG), 5, 12, $mainColor, 0);
textCenter($png_image,($width/6)+$widthShift, 140, "".$displayTempUnits, 6, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 3)+$widthShift, 140, $displayPressUnits, 6, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 4)+$widthShift, 140, $displayWindUnits, 6, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 5)+$widthShift, 140, $displayRainUnits, 6, 12, $mainColor, 0);
textCenter($png_image,($width/2)+$widthShift, 160, $pageURL, 3, 8, $mainColor, 0);
textCenter($png_image,710+$widthShift, 160, $licVar, 3, 8, $mainColor, 0);
}
else{
textLeft($png_image,92+$widthShift, 39, $text, 7, 17, $shadowColor, 0);
textLeft($png_image,90+$widthShift, 37, $text, 7, 17, $mainColor, 0);
textCenter($png_image,764+$widthShift, 42, $time, 8, 11, $shadowColor, 0);
textCenter($png_image,762+$widthShift, 40, $time, 8, 11, $mainColor, 0);
textCenter($png_image,766+$widthShift, 25, $date, 8, 10, $shadowColor, 0);
textCenter($png_image,764+$widthShift, 23, $date, 8, 10, $mainColor, 0);
textCenter($png_image,($width/6 + 2)+$widthShift, 75, $T, 7, 22, $shadowColor, 0);
textCenter($png_image,($width/6)+$widthShift, 74, $T, 7, 22, $mainColor, 0);
textCenter($png_image,($width/6 * 2 + 2)+$widthShift, 75, $H, 7, 22, $shadowColor, 0);
textCenter($png_image,($width/6 * 2)+$widthShift, 74, $H, 7, 22, $mainColor, 0);
textCenter($png_image,($width/6 * 3 + 2)+$widthShift, 75, $P, 7, 22, $shadowColor, 0);
textCenter($png_image,($width/6 * 3)+$widthShift, 74, $P, 7, 22, $mainColor, 0);
textCenter($png_image,($width/6 * 4 + 2)+$widthShift, 75, $W, 7, 22, $shadowColor, 0);
textCenter($png_image,($width/6 * 4)+$widthShift, 74, $W, 7, 22, $mainColor, 0);
textCenter($png_image,($width/6 * 5 + 2)+$widthShift, 75, $R, 7, 22, $shadowColor, 0);
textCenter($png_image,($width/6 * 5)+$widthShift, 74, $R, 7, 22, $mainColor, 0);
textCenter($png_image,($width/6 + 1)+$widthShift, 97, ("TODAY"), 3, 8, $shadowColor, 0);
textCenter($png_image,($width/6)+$widthShift, 96, ("TODAY"), 3, 8, $mainColor, 0);
textCenter($png_image,($width/6 * 2 + 1)+$widthShift, 97, ("TODAY"), 3, 8, $shadowColor, 0);
textCenter($png_image,($width/6 * 2)+$widthShift, 96, ("TODAY"), 3, 8, $mainColor, 0);
textCenter($png_image,($width/6 * 3 + 1)+$widthShift, 97, ("3 H"), 3, 8, $shadowColor, 0);
textCenter($png_image,($width/6 * 3)+$widthShift, 96, ("3 H"), 3, 8, $mainColor, 0);
textCenter($png_image,($width/6 * 4 + 1)+$widthShift, 97, ("MAX TODAY"), 3, 8, $shadowColor, 0);
textCenter($png_image,($width/6 * 4)+$widthShift, 96, ("MAX TODAY"), 3, 8, $mainColor, 0);
textCenter($png_image,($width/6)+$widthShift, 118, ($dailyMaxT." / ".$dailyMinT), 5, 12, $shadowColor, 0);
textCenter($png_image,($width/6 + 2)+$widthShift, 116, ($dailyMaxT." / ".$dailyMinT), 5, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 2)+$widthShift, 118, ($dailyMaxH." / ".$dailyMinH), 5, 12, $shadowColor, 0);
textCenter($png_image,($width/6 * 2 + 2)+$widthShift, 116, ($dailyMaxH." / ".$dailyMinH), 5, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 4)+$widthShift, 118, ($dailyMaxG), 5, 12, $shadowColor, 0);
textCenter($png_image,($width/6 * 4 + 2)+$widthShift, 116, ($dailyMaxG), 5, 12, $mainColor, 0);
textCenter($png_image,($width/6 + 1)+$widthShift, 142, "".$displayTempUnits, 6, 12, $shadowColor, 0);
textCenter($png_image,($width/6)+$widthShift, 140, "".$displayTempUnits, 6, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 2 + 2)+$widthShift, 142, '%', 6, 12, $shadowColor, 0);
textCenter($png_image,($width/6 * 2)+$widthShift, 140, '%', 6, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 3 + 2)+$widthShift, 142, $displayPressUnits, 6, 12, $shadowColor, 0);
textCenter($png_image,($width/6 * 3)+$widthShift, 140, $displayPressUnits, 6, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 4 + 2)+$widthShift, 142, $displayWindUnits, 6, 12, $shadowColor, 0);
textCenter($png_image,($width/6 * 4)+$widthShift, 140, $displayWindUnits, 6, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 5 + 2)+$widthShift, 142, $displayRainUnits, 6, 12, $shadowColor, 0);
textCenter($png_image,($width/6 * 5)+$widthShift, 140, $displayRainUnits, 6, 12, $mainColor, 0);
textCenter($png_image,($width/2 + 1)+$widthShift, 166, $pageURL, 3, 8, $shadowColor, 0);
textCenter($png_image,($width/2)+$widthShift, 165, $pageURL, 3, 8, $mainColor, 0);
textCenter($png_image,711+$widthShift, 166, $licVar, 3, 8, $shadowColor, 0);
textCenter($png_image,710+$widthShift, 165, $licVar, 3, 8, $mainColor, 0);
}
imagepng($png_image);
function textCenter($img, $x, $y, $text, $size, $ttfsize, $color, $angle) {
global $fontFace;
$gsSupport = gd_info();
if ($gsSupport["FreeType Support"] == 0){
$x -= (imagefontwidth($size) * strlen($text)) / 2;
$y -= (imagefontheight($size)) / 2;
imagestring($img, $size, $x, $y - 3, $text, $color);
}
else {
$box = imagettfbbox ($ttfsize, $angle, $fontFace, $text);
$x -= ($box[2] - $box[0]) / 2;
$y -= ($box[3] - $box[1]) / 2;
imagettftext ($img, $ttfsize, $angle, $x, $y, $color, $fontFace, $text);
}
}
function textLeft($img, $x, $y, $text, $size, $ttfsize, $color, $angle) {
global $fontFace;
$gsSupport = gd_info();
if ($gsSupport["FreeType Support"] == 0){
$x -= (imagefontwidth($size) * strlen($text));
$y -= (imagefontheight($size)) / 2;
imagestring($img, $size, $x, $y - 3, $text, $color);
}
else {
$box = imagettfbbox ($ttfsize, $angle, $fontFace, $text);
$x -= ($box[4] - $box[2]) ;
$y -= ($box[3] - $box[1]) / 2;
imagettftext ($img, $ttfsize, $angle, $x, $y, $color, $fontFace, $text);
}
}
function hex2rgb($hex){
$hex = str_replace("#", "", $hex);
if(strlen($hex) == 3) {
$r = hexdec(substr($hex,0,1).substr($hex,0,1));
$g = hexdec(substr($hex,1,1).substr($hex,1,1));
$b = hexdec(substr($hex,2,1).substr($hex,2,1));
}
else {
$r = hexdec(substr($hex,0,2));
$g = hexdec(substr($hex,2,2));
$b = hexdec(substr($hex,4,2));
}
$rgb = array($r, $g, $b);
return $rgb;
}
function roundRect($im,$x,$y,$cx,$cy,$rad,$col){
imagefilledrectangle($im,$x,$y+$rad,$cx,$cy-$rad,$col);
imagefilledrectangle($im,$x+$rad,$y,$cx-$rad,$cy,$col);
$dia = $rad*2;
imagefilledellipse($im, $x+$rad, $y+$rad, $rad*2, $dia, $col);
imagefilledellipse($im, $x+$rad, $cy-$rad, $rad*2, $dia, $col);
imagefilledellipse($im, $cx-$rad, $cy-$rad, $rad*2, $dia, $col);
imagefilledellipse($im, $cx-$rad, $y+$rad, $rad*2, $dia, $col);
}
if($licVar!=base64_decode("TWV0ZW90ZW1wbGF0ZQ==")){
echo "123";
}
?>
Did this file decode correctly?
Original Code
<?php
# INTERACTIVE STICKER for WU
# based on Stickers plugin for Meteotemplate
# http://www.meteotemplate.com
# Author: Jachym
# [email protected]
# Meteotemplate 2016
# License: free to use, Meteotemplate logo and text in bottom right corner must be left untouched
#####################################################################################################################
# SETTINGS
#
# see readme file for instructions how to use!
#####################################################################################################################
$stationTZ = "Europe/Prague"; // specify your timezone (see http://php.net/manual/en/timezones.php)
$stationCountry = "cz"; // lowercase two-letter ISO code of your country
$stationLat = 49.2; // your station latitude (in decimal numbers, negative for Southern hemisphere)
$stationLon = 16.4; // your station longitude (in decimal numbers, negative for Western hemisphere)
$timeFormat = "H:i"; // see PHP date formats
$dateFormat = "d-m-Y";
$pageURL = "http://www.meteotemplate.com"; // URL of your website
$WUID = "IJIHOMOR28";
$pressureUnits = "hPa"; // inHg or hPa
$rainUnits = "mm"; // in or mm
$temperatureUnits = "C"; // C or F
$windUnits = "km/h"; // mph, km/h or m/s
#####################################################################################################################
#
# DO NOT EDIT BELOW!!!
#
#####################################################################################################################
header('Content-type: image/png');
date_default_timezone_set($stationTZ);
$url = 'https://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID='.$WUID.'&month='.date("n").'&year='.date("Y").'&day='.date("j").'&format=1';
$rawData = file_get_contents($url);
if($rawData==""){
$rawData = curlMain($url,5);
}
$data = explode("<br>",trim($rawData));
$data = array_filter($data);
// get header
$header = explode(",",$data[0]);
for($i=0;$i<count($header);$i++){
$identify = getFields($header[$i],$i);
if($identify[0]!=""){
$parameters[$identify[0]] = $i;
$units[$identify[0]] = $identify[1];
}
}
if(count($data)>1){
$latestRow = explode(",",$data[(count($data)-1)]);
}
if(isset($latestRow[$parameters['T']])){
if($units['T']=="C" && $temperatureUnits=="F"){
$Traw = convertor($latestRow[$parameters['T']],"C","F");
$T = number_format($Traw,1,".","");
}
else if($units['T']=="F" && $temperatureUnits=="C"){
$Traw = convertor($latestRow[$parameters['T']],"F","C");
$T = number_format($Traw,1,".","");
}
else{
$T = number_format($latestRow[$parameters['T']],1,".","");
}
}
else{
$T = "-";
}
if(isset($latestRow[$parameters['W']])){
if($units['W']=="km/h" && $windUnits=="m/s"){
$Wraw = convertor($latestRow[$parameters['W']],"kmh","ms");
$W = number_format($Wraw,1,".","");
}
else if($units['W']=="km/h" && $windUnits=="mph"){
$Wraw = convertor($latestRow[$parameters['W']],"kmh","mph");
$W = number_format($Wraw,1,".","");
}
else if($units['W']=="m/s" && $windUnits=="km/h"){
$Wraw = convertor($latestRow[$parameters['W']],"ms","kmh");
$W = number_format($Wraw,1,".","");
}
else if($units['W']=="m/s" && $windUnits=="mph"){
$Wraw = convertor($latestRow[$parameters['W']],"ms","mph");
$W = number_format($Wraw,1,".","");
}
else if($units['W']=="mph" && $windUnits=="km/h"){
$Wraw = convertor($latestRow[$parameters['W']],"mph","kmh");
$W = number_format($Wraw,1,".","");
}
else if($units['W']=="mph" && $windUnits=="m/s"){
$Wraw = convertor($latestRow[$parameters['W']],"mph","ms");
$W = number_format($Wraw,1,".","");
}
else{
$W = number_format($latestRow[$parameters['W']],1,".","");
}
}
else{
$W = "-";
}
if(isset($latestRow[$parameters['H']])){
$H = number_format($latestRow[$parameters['H']],1,".","");
}
else{
$H = "-";
}
if(isset($latestRow[$parameters['P']])){
$currentP = $latestRow[$parameters['P']]; // for trend calculation
if($units['P']=="hPa" && $pressureUnits=="inHg"){
$Praw = convertor($latestRow[$parameters['P']],"hpa","inhg");
$P = number_format($Praw,2,".","");
}
else if($units['P']=="inHg" && $pressureUnits=="hPa"){
$Praw = convertor($latestRow[$parameters['P']],"inhg","hpa");
$P = number_format($Praw,1,".","");
}
else{
if($units['P']=="hPa"){
$P = number_format($latestRow[$parameters['P']],1,".","");
}
else{
$P = number_format($latestRow[$parameters['P']],2,".","");
}
}
}
else{
$P = "-";
}
if(isset($latestRow[$parameters['R']])){
if($units['R']=="mm" && $rainUnits=="in"){
$Rraw = convertor($latestRow[$parameters['R']],"mm","in");
$R = number_format($Rraw,2,".","");
}
else if($units['R']=="in" && $rainUnits=="mm"){
$Rraw = convertor($latestRow[$parameters['R']],"in","mm");
$R = number_format($Rraw,1,".","");
}
else{
if($units['R']=="mm"){
$R = number_format($latestRow[$parameters['R']],1,".","");
}
else{
$R = number_format($latestRow[$parameters['R']],2,".","");
}
}
}
else{
$R = "-";
}
if(isset($latestRow[0])){
$currentTime = strtotime($latestRow[0]);
}
else{
$currentTime = time();
}
if(isset($data[count($data)-2][$parameters['P']])){
$previousP = $data[count($data)-2][$parameters['P']];
$trendP = $currentP - $previousP;
}
else{
$trendP = 0;
}
for($i=1;$i<count($data);$i++){
$thisrow = explode(",",$data[$i]);
if($units['T']=="C" && $temperatureUnits=="F"){
$Traw = convertor($thisrow[$parameters['T']],"C","F");
$Traw = number_format($Traw,1,".","");
}
else if($units['T']=="F" && $temperatureUnits=="C"){
$Traw = convertor($thisrow[$parameters['T']],"F","C");
$Traw = number_format($Traw,1,".","");
}
else{
$Traw = number_format($thisrow[$parameters['T']],1,".","");
}
if($units['W']=="km/h" && $windUnits=="m/s"){
$Wraw = convertor($latestRow[$parameters['G']],"kmh","ms");
$G = number_format($Wraw,1,".","");
}
else if($units['W']=="km/h" && $windUnits=="mph"){
$Wraw = convertor($latestRow[$parameters['G']],"kmh","mph");
$G = number_format($Wraw,1,".","");
}
else if($units['W']=="m/s" && $windUnits=="km/h"){
$Wraw = convertor($latestRow[$parameters['G']],"ms","kmh");
$G = number_format($Wraw,1,".","");
}
else if($units['W']=="m/s" && $windUnits=="mph"){
$Wraw = convertor($latestRow[$parameters['G']],"ms","mph");
$G = number_format($Wraw,1,".","");
}
else if($units['W']=="mph" && $windUnits=="km/h"){
$Wraw = convertor($latestRow[$parameters['G']],"mph","kmh");
$G = number_format($Wraw,1,".","");
}
else if($units['W']=="mph" && $windUnits=="m/s"){
$Wraw = convertor($latestRow[$parameters['G']],"mph","ms");
$G = number_format($Wraw,1,".","");
}
else{
$G = number_format($latestRow[$parameters['G']],1,".","");
}
$temperatures[] = $Traw;
$humidities[] = $thisrow[$parameters['H']];
$gusts[] = $G;
}
if(count($temperatures)>0){
$dailyMinT = number_format(min($temperatures),1,".","");
$dailyMaxT = number_format(max($temperatures),1,".","");
}
else{
$dailyMinT = "-";
$dailyMaxT = "-";
}
if(count($humidities)>0){
$dailyMinH = number_format(min($humidities),1,".","");
$dailyMaxH = number_format(max($humidities),1,".","");
}
else{
$dailyMinH = "-";
$dailyMaxH = "-";
}
if(count($gusts)>0){
$dailyMaxG = number_format(max($gusts),1,".","");
}
else{
$dailyMaxG = "-";
}
function getFields($parameter,$field){
$parameter = trim(strtolower($parameter));
$paramID = "";
$units = "";
$number = "";
if($parameter=="temperaturec"){
$paramID = 'T';
$units = "C";
$number = $field;
}
if($parameter=="temperaturef"){
$paramID = 'T';
$units = "F";
$number = $field;
}
if($parameter=="pressurehpa"){
$paramID = 'P';
$units = "hPa";
$number = $field;
}
if($parameter=="pressurein"){
$paramID = 'P';
$units = "inHg";
$number = $field;
}
if($parameter=="windspeedkmh"){
$paramID = 'W';
$units = "km/h";
$number = $field;
}
if($parameter=="windspeedmph"){
$paramID = 'W';
$units = "mph";
$number = $field;
}
if($parameter=="windspeedmps"){
$paramID = 'W';
$units = "m/s";
$number = $field;
}
if($parameter=="windspeedms"){
$paramID = 'W';
$units = "m/s";
$number = $field;
}
if($parameter=="windspeedgustkmh"){
$paramID = 'G';
$units = "km/h";
$number = $field;
}
if($parameter=="windspeedgustmph"){
$paramID = 'G';
$units = "mph";
$number = $field;
}
if($parameter=="windspeedgustmps"){
$paramID = 'G';
$units = "m/s";
$number = $field;
}
if($parameter=="windspeedgustms"){
$paramID = 'G';
$units = "m/s";
$number = $field;
}
if($parameter=="humidity"){
$paramID = 'H';
$units = "%";
$number = $field;
}
if($parameter=="dailyrainmm"){
$paramID = 'R';
$units = "mm";
$number = $field;
}
if($parameter=="dailyrainin"){
$paramID = 'R';
$units = "in";
$number = $field;
}
return array($paramID,$units,$number);
}
function curlMain($url,$timeout){
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows NT 6.1; rv:19.0) Gecko/20100101 Firefox/19.0");
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
function convertor($n,$unit1,$unit2){
// prepare input
$unit1 = trim(strtolower($unit1));
$unit2 = trim(strtolower($unit2));
$unit1 = str_replace("/","",$unit1);
$unit2 = str_replace("/","",$unit2);
$unit1 = str_replace("kts","kt",$unit1);
$unit2 = str_replace("kts","kt",$unit2);
$unit1 = str_replace("knots","kt",$unit1);
$unit2 = str_replace("knots","kt",$unit2);
$unit1 = str_replace("kph","kmh",$unit1);
$unit2 = str_replace("kph","kmh",$unit2);
$unit1 = str_replace("mb","hpa",$unit1);
$unit2 = str_replace("mb","hpa",$unit2);
$unit1 = str_replace("miles","mi",$unit1);
$unit2 = str_replace("miles","mi",$unit2);
$unit1 = str_replace("feet","ft",$unit1);
$unit2 = str_replace("feet","ft",$unit2);
$unit1 = str_replace("foot","ft",$unit1);
$unit2 = str_replace("foot","ft",$unit2);
// return same units
if($unit1==$unit2){
return $n;
}
// temperature
else if($unit1=="c" && $unit2=="f"){
return $n*1.8 + 32;
}
else if($unit1=="f" && $unit2=="c"){
return ($n - 32)/1.8;
}
// wind speed
else if($unit1=="ms" && $unit2=="kmh"){
return $n * 3.6;
}
else if($unit1=="ms" && $unit2=="mph"){
return $n * 2.23694;
}
else if($unit1=="ms" && $unit2=="kt"){
return $n * 1.943844;
}
else if($unit1=="kmh" && $unit2=="ms"){
return $n / 3.6;
}
else if($unit1=="kmh" && $unit2=="mph"){
return $n * 0.621371;
}
else if($unit1=="kmh" && $unit2=="kt"){
return $n * 0.539957;
}
else if($unit1=="mph" && $unit2=="ms"){
return $n * 0.44704;
}
else if($unit1=="mph" && $unit2=="kmh"){
return $n * 1.609344;
}
else if($unit1=="mph" && $unit2=="kt"){
return $n * 0.868976;
}
else if($unit1=="kt" && $unit2=="ms"){
return $n * 0.514444;
}
else if($unit1=="kt" && $unit2=="kmh"){
return $n * 1.852;
}
else if($unit1=="kt" && $unit2=="mph"){
return $n * 1.150779;
}
// pressure
else if($unit1=="hpa" && $unit2=="inhg"){
return $n * 0.02952998;
}
else if($unit1=="hpa" && $unit2=="mmhg"){
return $n * 0.750063755;
}
else if($unit1=="inhg" && $unit2=="hpa"){
return $n * 33.863881;
}
else if($unit1=="inhg" && $unit2=="mmhg"){
return $n * 25.400069;
}
else if($unit1=="mmhg" && $unit2=="hpa"){
return $n * 1.3332239;
}
else if($unit1=="mmhg" && $unit2=="inhg"){
return $n * 0.03937;
}
// precipitation
else if($unit1=="mm" && $unit2=="in"){
return $n * 0.0393701;
}
else if($unit1=="in" && $unit2=="mm"){
return $n * 25.4;
}
// distance
else if($unit1=="km" && $unit2=="mi"){
return $n * 0.621371;
}
else if($unit1=="mi" && $unit2=="km"){
return $n * 1.60934;
}
else if($unit1=="km" && $unit2=="ft"){
return $n * 3280.84;
}
else if($unit1=="ft" && $unit2=="km"){
return $n * 0.0003048;
}
else if($unit1=="m" && $unit2=="ft"){
return $n * 3.28084;
}
else if($unit1=="ft" && $unit2=="m"){
return $n * 0.3048;
}
}
// apply conversions
$displayTempUnits = $temperatureUnits;
$displayPressUnits = $pressureUnits;
$displayRainUnits = $rainUnits;
$displayWindUnits = $windUnits;
$time = date($timeFormat,$currentTime);
$date = date($dateFormat,$currentTime);
$stationTimezone = new DateTimeZone($stationTZ);
$stationOffset = $stationTimezone->getOffset(new DateTime)/3600;
// get sunrise and sunset times
$sunRiseTS = date_sunrise(time(),SUNFUNCS_RET_TIMESTAMP,$stationLat,$stationLon,90.5);
$sunSetTS = date_sunset(time(),SUNFUNCS_RET_TIMESTAMP,$stationLat,$stationLon,90.5);
// current time
$currentTime = time();
// before sunrise
if($currentTime<($sunRiseTS-30*60)){
$dayTime = "night";
}
// after sunset
else if($currentTime>($sunSetTS+30*60)){
$dayTime = "night";
}
// hour within sunrise
else if($currentTime>=($sunRiseTS-30*60) && $currentTime<=($sunRiseTS+30*60)){
$dayTime = "sunrise";
}
// hour within sunset
else if($currentTime>=($sunSetTS-30*60) && $currentTime<=($sunSetTS+30*60)){
$dayTime = "sunset";
}
// else must be day
else{
$dayTime = "day";
}
// get parameters
if(isset($_GET['text'])){
$text = $_GET['text'];
}
else{
$text = "Meteotemplate";
}
if(isset($_GET['font'])){
$fontFace = "fonts/".$_GET['font'].".ttf";
}
else{
$fontFace = "fonts/Ubuntu-Regular.ttf";
}
if(isset($_GET['bg'])){
$bgURL = 'bgs/'.$_GET['bg'].'.jpg';
$bgNumber = $_GET['bg'];
}
else{
$bgURL = 'bgs/10.jpg';
$bgNumber = 10;
}
if(isset($_GET['border'])){
$border = $_GET['border'];
}
else{
$border = 5;
}
if(isset($_GET['bgColor'])){
$bgColor = hex2rgb($_GET['bgColor']);
}
else{
$bgColor = hex2rgb('000');
}
if(isset($_GET['shadow'])){
if($_GET['shadow']==0){
$shadow = false;
}
else{
$shadow = true;
}
}
else{
$shadow = false;
}
if(isset($_GET['color'])){
$stickerColor = $_GET['color'];
}
else{
$stickerColor = "white";
}
if($stickerColor=="white"){
$shadowColor = "black";
}
else{
$shadowColor = "white";
}
if($stickerColor=="black"){
if($trendP>0){
$imageP = "trendUpBlack.png";
}
if($trendP==0){
$imageP = "trendNeutralBlack.png";
}
if($trendP<0){
$imageP = "trendDownBlack.png";
}
}
else{
if($trendP>0){
$imageP = "trendUp.png";
}
if($trendP==0){
$imageP = "trendNeutral.png";
}
if($trendP<0){
$imageP = "trendDown.png";
}
}
// get type
if(isset($_GET['type'])){
if($_GET['type']=="random"){
$bgImagesAvailable = array_filter(glob('bgs/*.jpg'));
foreach($bgImagesAvailable as $availableImage){
$bgNames [] = $availableImage;
}
$bgNumber = rand(0,(count($bgNames)-1));
$bgURL = $bgNames[$bgNumber];
$shadow = 1;
}
if($_GET['type']=="interactive"){
$shadow = 1;
if($dayTime=='night'){
$items = array(27,68,145,146,40,38);
$bgNumber = $items[array_rand($items)];
$bgURL = 'bgs/'.$bgNumber.'.jpg';
$stickerColor = 'white';
$shadowColor = 'black';
}
if($dayTime=='day'){
$items = array(13,139,140,141,171,172);
$bgNumber = $items[array_rand($items)];
$bgURL = 'bgs/'.$bgNumber.'.jpg';
$stickerColor = 'white';
$shadowColor = 'black';
}
if($dayTime=='sunrise'){
$items = array(17,51,16,142,151,152);
$bgNumber = $items[array_rand($items)];
$bgURL = 'bgs/'.$bgNumber.'.jpg';
$stickerColor = 'white';
$shadowColor = 'black';
}
if($dayTime=='sunset'){
$items = array(17,51,16,137,138,151,152,177);
$bgNumber = $items[array_rand($items)];
$bgURL = 'bgs/'.$bgNumber.'.jpg';
$stickerColor = 'white';
$shadowColor = 'black';
}
if($RR>0){
$items = array(65,143,144,150);
$bgNumber = $items[array_rand($items)];
$bgURL = 'bgs/'.$bgNumber.'.jpg';
$stickerColor = 'white';
$shadowColor = 'black';
}
if($S>800){
$items = array(23);
$bgNumber = $items[array_rand($items)];
$bgURL = 'bgs/'.$bgNumber.'.jpg';
$stickerColor = 'black';
$shadowColor = 'white';
}
}
}
$widthShift = 0;
if(isset($_GET['image'])){
if($_GET['image']!="random"){
$thumbNail = true;
$widthShift = 175;
$customImage = imagecreatefrompng('imgs/'.$_GET['image'].".png");
}
else if($_GET['image']=="random"){
$thumbNail = true;
$widthShift = 175;
$customImagesAvailable = array_filter(glob('imgs/*'));
foreach($customImagesAvailable as $availableCustomImage){
$customNames [] = $availableCustomImage;
}
$customImageNumber = rand(0,(count($customNames)-1));
$customImage = imagecreatefrompng($customImagesAvailable[$customImageNumber]);
}
else{
$thumbNail = false;
}
}
else{
$thumbNail = false;
}
$width = 800;
if($thumbNail){
$widthImage = $width + $widthShift;
}
else{
$widthImage = $width;
}
$height = 170;
$png_image = imagecreatetruecolor($widthImage, $height);
imagealphablending( $png_image, true );
imagesavealpha( $png_image, true );
$colorWhite = hex2rgb("#660000");
$white = imagecolorallocate($png_image, 255, 255, 255);
$black = imagecolorallocate($png_image, 0, 0, 0);
$bgColorFinal = imagecolorallocate($png_image, $bgColor[0], $bgColor[1], $bgColor[2]);
imagefill ( $png_image , 0 ,0 , $bgColorFinal );
if($stickerColor=="black"){
$mainColor = $black;
$shadowColor = $white;
}
else{
$mainColor = $white;
$shadowColor = $black;
}
$bgImage = imagecreatefromjpeg($bgURL);
imagecopy($png_image, $bgImage, $widthShift+$border, $border, 0, 0, (800-$border*2), (170-$border*2));
$icon1 = imagecreatefrompng('flags/'.$stationCountry.'.png');
imagealphablending( $icon1, true );
imagesavealpha( $icon1, true );
imagecopy($png_image, $icon1, 2+$widthShift, 2, 0, 0, 80, 80);
if($thumbNail){
imagealphablending($customImage, true );
imagesavealpha( $customImage, true );
imagecopy($png_image, $customImage, $border, $border, 0, 0, 170, 170-$border*2);
}
if(!$shadow){
if($stickerColor=="black"){
$icon2 = imagecreatefrompng('logoSmallBlack.png');
}
else{
$icon2 = imagecreatefrompng('logoSmall.png');
}
imagealphablending( $icon2, true );
imagesavealpha( $icon2, true );
imagecopy($png_image, $icon2, 748+$widthShift, 112, 0, 0, 50, 50);
}
else{
if($stickerColor=="black"){
$icon2 = imagecreatefrompng('logoSmallBlack.png');
$icon2shadow = imagecreatefrompng('logoSmall.png');
}
else{
$icon2 = imagecreatefrompng('logoSmall.png');
$icon2shadow = imagecreatefrompng('logoSmallBlack.png');
}
imagealphablending( $icon2shadow, true );
imagesavealpha( $icon2shadow, true );
imagecopy($png_image, $icon2shadow, 749+$widthShift, 113, 0, 0, 50, 50);
imagealphablending( $icon2, true );
imagesavealpha( $icon2, true );
imagecopy($png_image, $icon2, 748+$widthShift, 112, 0, 0, 50, 50);
}
$pressureIcon = imagecreatefrompng($imageP);
imagealphablending( $pressureIcon, true );
imagesavealpha( $pressureIcon, true );
imagecopy($png_image, $pressureIcon, ($width/6 * 3 - 15)+$widthShift, 96, 0, 0, 30, 30);
if(!$shadow){
if($stickerColor=="black"){
$stationIcon = imagecreatefrompng('stationBlack.png');
}
else{
$stationIcon = imagecreatefrompng('station.png');
}
imagealphablending( $stationIcon, true );
imagesavealpha( $stationIcon, true );
imagecopy($png_image, $stationIcon, 17+$widthShift, 100, 0, 0, 50, 50);
}
else{
if($stickerColor=="black"){
$stationIcon = imagecreatefrompng('stationBlack.png');
$stationIconShadow = imagecreatefrompng('station.png');
}
else{
$stationIcon = imagecreatefrompng('station.png');
$stationIconShadow = imagecreatefrompng('stationBlack.png');
}
imagealphablending( $stationIconShadow, true );
imagesavealpha( $stationIconShadow, true );
imagecopy($png_image, $stationIconShadow, 18+$widthShift, 101, 0, 0, 50, 50);
imagealphablending( $stationIcon, true );
imagesavealpha( $stationIcon, true );
imagecopy($png_image, $stationIcon, 17+$widthShift, 100, 0, 0, 50, 50);
}
$licVar = base64_decode("TWV0ZW90ZW1wbGF0ZQ==");
if(!$shadow){
textLeft($png_image,90+$widthShift, 36, $text, 7, 17, $mainColor, 0);
textCenter($png_image,762+$widthShift, 40, $time, 8, 11, $mainColor, 0);
textCenter($png_image,762+$widthShift, 22, $date, 8, 10, $mainColor, 0);
textCenter($png_image,($width/6 + 1)+$widthShift, 75, $T, 7, 22, $mainColor, 0);
textCenter($png_image,($width/6 * 2 + 1)+$widthShift, 75, $H, 7, 22, $mainColor, 0);
textCenter($png_image,($width/6 * 3 + 1)+$widthShift, 75, $P, 7, 22, $mainColor, 0);
textCenter($png_image,($width/6 * 4 + 1)+$widthShift, 75, $W, 7, 22, $mainColor, 0);
textCenter($png_image,($width/6 * 5 + 1)+$widthShift, 75, $R, 7, 22, $mainColor, 0);
textCenter($png_image,($width/6)+$widthShift, 96, ("TODAY"), 3, 8, $mainColor, 0);
textCenter($png_image,($width/6 * 2)+$widthShift, 96, ("%"), 5, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 3)+$widthShift, 96, ("3 H"), 3, 8, $mainColor, 0);
textCenter($png_image,($width/6 * 4)+$widthShift, 96, ("MAX TODAY"), 3, 8, $mainColor, 0);
textCenter($png_image,($width/6)+$widthShift, 117, ($dailyMaxT." / ".$dailyMinT), 5, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 2)+$widthShift, 117, ($dailyMaxH." / ".$dailyMinH), 5, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 4)+$widthShift, 117, ($dailyMaxG), 5, 12, $mainColor, 0);
textCenter($png_image,($width/6)+$widthShift, 140, "".$displayTempUnits, 6, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 3)+$widthShift, 140, $displayPressUnits, 6, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 4)+$widthShift, 140, $displayWindUnits, 6, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 5)+$widthShift, 140, $displayRainUnits, 6, 12, $mainColor, 0);
textCenter($png_image,($width/2)+$widthShift, 160, $pageURL, 3, 8, $mainColor, 0);
textCenter($png_image,710+$widthShift, 160, $licVar, 3, 8, $mainColor, 0);
}
else{
textLeft($png_image,92+$widthShift, 39, $text, 7, 17, $shadowColor, 0);
textLeft($png_image,90+$widthShift, 37, $text, 7, 17, $mainColor, 0);
textCenter($png_image,764+$widthShift, 42, $time, 8, 11, $shadowColor, 0);
textCenter($png_image,762+$widthShift, 40, $time, 8, 11, $mainColor, 0);
textCenter($png_image,766+$widthShift, 25, $date, 8, 10, $shadowColor, 0);
textCenter($png_image,764+$widthShift, 23, $date, 8, 10, $mainColor, 0);
textCenter($png_image,($width/6 + 2)+$widthShift, 75, $T, 7, 22, $shadowColor, 0);
textCenter($png_image,($width/6)+$widthShift, 74, $T, 7, 22, $mainColor, 0);
textCenter($png_image,($width/6 * 2 + 2)+$widthShift, 75, $H, 7, 22, $shadowColor, 0);
textCenter($png_image,($width/6 * 2)+$widthShift, 74, $H, 7, 22, $mainColor, 0);
textCenter($png_image,($width/6 * 3 + 2)+$widthShift, 75, $P, 7, 22, $shadowColor, 0);
textCenter($png_image,($width/6 * 3)+$widthShift, 74, $P, 7, 22, $mainColor, 0);
textCenter($png_image,($width/6 * 4 + 2)+$widthShift, 75, $W, 7, 22, $shadowColor, 0);
textCenter($png_image,($width/6 * 4)+$widthShift, 74, $W, 7, 22, $mainColor, 0);
textCenter($png_image,($width/6 * 5 + 2)+$widthShift, 75, $R, 7, 22, $shadowColor, 0);
textCenter($png_image,($width/6 * 5)+$widthShift, 74, $R, 7, 22, $mainColor, 0);
textCenter($png_image,($width/6 + 1)+$widthShift, 97, ("TODAY"), 3, 8, $shadowColor, 0);
textCenter($png_image,($width/6)+$widthShift, 96, ("TODAY"), 3, 8, $mainColor, 0);
textCenter($png_image,($width/6 * 2 + 1)+$widthShift, 97, ("TODAY"), 3, 8, $shadowColor, 0);
textCenter($png_image,($width/6 * 2)+$widthShift, 96, ("TODAY"), 3, 8, $mainColor, 0);
textCenter($png_image,($width/6 * 3 + 1)+$widthShift, 97, ("3 H"), 3, 8, $shadowColor, 0);
textCenter($png_image,($width/6 * 3)+$widthShift, 96, ("3 H"), 3, 8, $mainColor, 0);
textCenter($png_image,($width/6 * 4 + 1)+$widthShift, 97, ("MAX TODAY"), 3, 8, $shadowColor, 0);
textCenter($png_image,($width/6 * 4)+$widthShift, 96, ("MAX TODAY"), 3, 8, $mainColor, 0);
textCenter($png_image,($width/6)+$widthShift, 118, ($dailyMaxT." / ".$dailyMinT), 5, 12, $shadowColor, 0);
textCenter($png_image,($width/6 + 2)+$widthShift, 116, ($dailyMaxT." / ".$dailyMinT), 5, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 2)+$widthShift, 118, ($dailyMaxH." / ".$dailyMinH), 5, 12, $shadowColor, 0);
textCenter($png_image,($width/6 * 2 + 2)+$widthShift, 116, ($dailyMaxH." / ".$dailyMinH), 5, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 4)+$widthShift, 118, ($dailyMaxG), 5, 12, $shadowColor, 0);
textCenter($png_image,($width/6 * 4 + 2)+$widthShift, 116, ($dailyMaxG), 5, 12, $mainColor, 0);
textCenter($png_image,($width/6 + 1)+$widthShift, 142, "".$displayTempUnits, 6, 12, $shadowColor, 0);
textCenter($png_image,($width/6)+$widthShift, 140, "".$displayTempUnits, 6, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 2 + 2)+$widthShift, 142, '%', 6, 12, $shadowColor, 0);
textCenter($png_image,($width/6 * 2)+$widthShift, 140, '%', 6, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 3 + 2)+$widthShift, 142, $displayPressUnits, 6, 12, $shadowColor, 0);
textCenter($png_image,($width/6 * 3)+$widthShift, 140, $displayPressUnits, 6, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 4 + 2)+$widthShift, 142, $displayWindUnits, 6, 12, $shadowColor, 0);
textCenter($png_image,($width/6 * 4)+$widthShift, 140, $displayWindUnits, 6, 12, $mainColor, 0);
textCenter($png_image,($width/6 * 5 + 2)+$widthShift, 142, $displayRainUnits, 6, 12, $shadowColor, 0);
textCenter($png_image,($width/6 * 5)+$widthShift, 140, $displayRainUnits, 6, 12, $mainColor, 0);
textCenter($png_image,($width/2 + 1)+$widthShift, 166, $pageURL, 3, 8, $shadowColor, 0);
textCenter($png_image,($width/2)+$widthShift, 165, $pageURL, 3, 8, $mainColor, 0);
textCenter($png_image,711+$widthShift, 166, $licVar, 3, 8, $shadowColor, 0);
textCenter($png_image,710+$widthShift, 165, $licVar, 3, 8, $mainColor, 0);
}
imagepng($png_image);
function textCenter($img, $x, $y, $text, $size, $ttfsize, $color, $angle) {
global $fontFace;
$gsSupport = gd_info();
if ($gsSupport["FreeType Support"] == 0){
$x -= (imagefontwidth($size) * strlen($text)) / 2;
$y -= (imagefontheight($size)) / 2;
imagestring($img, $size, $x, $y - 3, $text, $color);
}
else {
$box = imagettfbbox ($ttfsize, $angle, $fontFace, $text);
$x -= ($box[2] - $box[0]) / 2;
$y -= ($box[3] - $box[1]) / 2;
imagettftext ($img, $ttfsize, $angle, $x, $y, $color, $fontFace, $text);
}
}
function textLeft($img, $x, $y, $text, $size, $ttfsize, $color, $angle) {
global $fontFace;
$gsSupport = gd_info();
if ($gsSupport["FreeType Support"] == 0){
$x -= (imagefontwidth($size) * strlen($text));
$y -= (imagefontheight($size)) / 2;
imagestring($img, $size, $x, $y - 3, $text, $color);
}
else {
$box = imagettfbbox ($ttfsize, $angle, $fontFace, $text);
$x -= ($box[4] - $box[2]) ;
$y -= ($box[3] - $box[1]) / 2;
imagettftext ($img, $ttfsize, $angle, $x, $y, $color, $fontFace, $text);
}
}
function hex2rgb($hex){
$hex = str_replace("#", "", $hex);
if(strlen($hex) == 3) {
$r = hexdec(substr($hex,0,1).substr($hex,0,1));
$g = hexdec(substr($hex,1,1).substr($hex,1,1));
$b = hexdec(substr($hex,2,1).substr($hex,2,1));
}
else {
$r = hexdec(substr($hex,0,2));
$g = hexdec(substr($hex,2,2));
$b = hexdec(substr($hex,4,2));
}
$rgb = array($r, $g, $b);
return $rgb;
}
function roundRect($im,$x,$y,$cx,$cy,$rad,$col){
imagefilledrectangle($im,$x,$y+$rad,$cx,$cy-$rad,$col);
imagefilledrectangle($im,$x+$rad,$y,$cx-$rad,$cy,$col);
$dia = $rad*2;
imagefilledellipse($im, $x+$rad, $y+$rad, $rad*2, $dia, $col);
imagefilledellipse($im, $x+$rad, $cy-$rad, $rad*2, $dia, $col);
imagefilledellipse($im, $cx-$rad, $cy-$rad, $rad*2, $dia, $col);
imagefilledellipse($im, $cx-$rad, $y+$rad, $rad*2, $dia, $col);
}
if($licVar!=base64_decode("TWV0ZW90ZW1wbGF0ZQ==")){
echo "123";
}
?>
Function Calls
header | 1 |
Stats
MD5 | 2ca61310b68f2b66e03e7d09a62807e3 |
Eval Count | 0 |
Decode Time | 264 ms |