]>
git.r.bdr.sh - rbdr/r.bdr.sh/blob - jekyll/clima/index.php
c8b8dc6bed74b406f0c3c3d38465c2b2acc0e062
8 /******************************
10 *******************************
11 * 0.1 -> Initial Release *
12 * 0.2 -> Config options *
13 * 0.3 -> Day and Night *
14 *******************************/
17 /*Weather.com configuration
18 ********************************/
19 $citycode = 'MXCA0026'; //Zip Code (US) or City code according to weather.com
20 $partnerid = '1140062701'; //Partner ID
21 $license = '5b323d77586070aa'; //License number
24 ********************************/
25 $nightbackground = '#222'; //main colors.
26 $daybackground = '#fff';
28 $daymaincolor = '#666';
29 $nightmaincolor = '#e1e1e1;';
31 $taglinecolor = '#999';
33 $coldcolor = '#78d6fd'; //Colors for each temperature.
34 $coolcolor = '#1b95fb';
35 $temperatecolor = '#999';
36 $warmcolor = '#ff9226';
37 $hotcolor = '#ff1818';
40 *******************************/
41 $maintext = 'Juárez está:';
42 $title = '¿Cómo está el clima en Juárez?';
44 $coldstring = 'frio.'; //string for each temperature.
45 $coolstring = 'fresco.';
46 $temperatestring = 'templado.';
47 $warmstring = 'cálido.';
48 $hotstring = 'caliente.';
50 $coldtagline = '(abrigate bien.)'; //tagline for each temperature.
51 $cooltagline = '(perfecto para un saco.)';
52 $temperatetagline = '(ni fu ni fa.)';
53 $warmtagline = '(como para estar afuera.)';
54 $hottagline = '(hidrátate bien.)';
56 /*Temperature Configuration
57 ******************************/
58 $coldlimit = 15; //How many degrees? (celsius)
65 /******************************
67 *******************************
68 * Don't edit below this part *
69 * unless you know what you're *
71 *******************************
72 * It's not that hard really. *
73 * but it's better if we leave *
74 * it like it is. Unless you *
75 * like customizing the shit *
77 *******************************/
80 $ch = curl_init('http://xoap.weather.com/weather/local/'.$citycode.'?cc=*&link=xoap&prod=xoap&par='.$partnerid.'&key='.$license.''); //Initialize curl.
82 curl_setopt($ch, CURLOPT_RETURNTRANSFER
, true); //More curl config
83 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT
, 4);
85 $data = curl_exec($ch); //this is your xml stuff
88 $xml = new SimpleXmlElement($data, LIBXML_NOCDATA
); //now let's make an XmlElement
89 $feelslike = $xml->cc
->flik
; //This is the "Feel's Like temp"
90 $sunset = date('G.i',strtotime($xml->loc
->suns
));
91 $sunrise = date('G.i',strtotime($xml->loc
->sunr
));
92 $now = date('G.i',time()-28800);
93 $feelslike = ($feelslike -32)*5/9; //Convert fahrenheit to celsius.
95 //now let's get the sponsored links. Stupid EULA.
96 $sponsors = '<a href="'.$xml->lnks
->link
[0]->l
.'">'.$xml->lnks
->link
[0]->t
.'</a> · ';
97 $sponsors .= '<a href="'.$xml->lnks
->link
[1]->l
.'">'.$xml->lnks
->link
[1]->t
.'</a> · ';
98 $sponsors .= '<a href="'.$xml->lnks
->link
[2]->l
.'">'.$xml->lnks
->link
[2]->t
.'</a> · ';
99 $sponsors .= '<a href="'.$xml->lnks
->link
[3]->l
.'">'.$xml->lnks
->link
[3]->t
.'</a>';
102 if(isset($_GET['temp'])){
103 $feelslike = $_GET['temp']; //This overrides the weather.com temperature for debugging.
105 if(isset($_GET['now'])){
106 $now = $_GET['now']; //This overrides the weather.com temperature for debugging.
110 echo '<?xml version="1.0" encoding="UTF-8"?>
111 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
112 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
115 <html xmlns
="http://www.w3.org/1999/xhtml" xml
:lang
="en">
117 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8" />
118 <title
><?php
echo $title; ?></title
>
119 <style type
="text/css">
127 if($now > $sunrise && $now < $sunset){
128 echo 'background-color:'.$daybackground.';';
130 echo 'background-color:'.$nightbackground.';';
133 font
-family
:Helvetica
,Arial
,sans
-serif
;
135 if($now > $sunrise && $now < $sunset){
136 echo 'color:'.$daymaincolor.';';
138 echo 'color:'.$nightmaincolor.';';
158 letter
-spacing
: .1em
;
159 color
: <?php
echo $taglinecolor; ?>;
163 color
: <?php
echo $coldcolor?>;
166 color
: <?php
echo $coolcolor?>;
168 #container .temperate{
169 color
: <?php
echo $temperatecolor?>;
172 color
: <?php
echo $warmcolor?>;
175 color
: <?php
echo $hotcolor?>;
193 <span
><?php
echo $maintext; ?></span
><br
/>
196 /******************************
198 *******************************
199 * I guess the following part *
200 * is not that dangerous, but *
201 * make sure you know what *
203 *******************************/
205 if($feelslike < $coldlimit){ echo '<p class="cold">'.$coldstring
.'</p><span class="rec">'.$coldtagline
.'</span>'; }
206 else if($feelslike < $coollimit){ echo '<p class="cool">'.$coolstring
.'</p><span class="rec">'.$cooltagline
.'</span>'; }
207 else if($feelslike < $temperatelimit){ echo '<p class="temperate">'.$temperatestring
.'</p><span class="rec">'.$temperatetagline
.'</span>'; }
208 else if($feelslike < $warmlimit){ echo '<p class="warm">'.$warmstring
.'</p><span class="rec">'.$warmtagline
.'</span>'; }
209 else{
echo '<p class="hot">'.$hotstring
.'</p><span class="rec">'.$hottagline
.'</span>'; }
212 <!-- <div id
="footer">
213 Powered by
: <a href
="http://weather.com"><img src
="TWClogo_31px.png" alt
="The Weather Channel" /></a
> Sponsored by
: <?php
echo $sponsors; ?>