Exemplo n.º 1
0
 function GetWeatherByID($arg)
 {
     if (!is_numeric($arg)) {
         return FALSE;
     }
     $db = new Db();
     $WeatherID = $db->quote($arg);
     $results = $db->select("SELECT * from Weather where WeatherID = {$WeatherID} limit 1");
     if ($results) {
         $weather = new weather();
         foreach ($results as $result) {
             $weather->hydrate($result);
         }
         return $weather;
     } else {
         return $results;
     }
 }
Exemplo n.º 2
0
} else {
    if (isset($_ENV["TMP"])) {
        $cachedir = $_ENV["TMP"];
    } else {
        if (isset($_ENV["TMPDIR"])) {
            $cachedir = $_ENV["TMPDIR"];
        } else {
            $cachedir = "/tmp";
        }
    }
}
$cachedir = str_replace('\\\\', '/', $cachedir);
if (substr($cachedir, -1) != '/') {
    $cachedir .= '/';
}
$weather_chile = new weather("CIXX0020", 3600, "C", $cachedir);
// Parse the weather object via cached
// This checks if there's an valid cache object allready. if yes
// it takes the local object data, what's much FASTER!!! if it
// is expired, it refreshes automatically from rss online!
$weather_chile->parsecached();
// => RECOMMENDED!
// allway refreshes from rss online. NOT SO FAST.
//$weather_chile->parse(); // => NOT recommended!
// -------------------
// OUTPUT
// -------------------
// VARIOUS
print "<h1>Various</h1>";
print "title: " . $weather_chile->forecast['TITLE'] . "<br>";
// Yahoo! Weather - Santiago, CI
 private function parse_xml($xData)
 {
     libxml_use_internal_errors(true);
     try {
         $weather = new SimpleXMLElement($xData);
     } catch (Exception $err) {
         // Set current exception message last getMessage()
         throw new Exception($err->getMessage());
     }
     // Select the current_conditions node ($cNode)
     if (!isset($weather->weather[0]->current_conditions)) {
         throw new Exception("Unable to find data for the specified location");
     }
     $cNode = $weather->weather[0]->current_conditions;
     // ========= Set up our current conditions array ====================
     // Tempreature - temp_f Fahrenheit, temp_c celsius - set as floats.
     $this->_wData['current']['temp_f'] = $cNode->temp_f->attributes()->data;
     $this->_wData['current']['temp_c'] = weather::to_celsius($this->_wData['current']['temp_f']);
     // Condition
     $this->_wData['current']['condition'] = $cNode->condition->attributes()->data;
     // Condition Icon - icon url is not absolute, append google.com
     $this->_wData['current']['icon'] = "http://www.google.com" . $cNode->icon->attributes()->data;
     // Wind Condition
     $this->_wData['current']['wind'] = $cNode->wind_condition->attributes()->data;
     // ============= Set up our forecast array =============
     $fNode = $weather->weather[0]->forecast_conditions;
     // Iterate through each day of the week and create an assoc array.
     foreach ($fNode as $forecast) {
         // Get the day.
         $day = (string) $forecast->day_of_week->attributes()->data;
         // Insert an array of info for that day
         $this->_wData['forecast'][$day] = array("day" => $day, "high" => $forecast->high->attributes()->data, "low" => $forecast->low->attributes()->data, "icon" => "http://www.google.com" . $forecast->icon->attributes()->data, "condition" => $forecast->condition->attributes()->data);
     }
     //foreach ($fNode as $forecast)
     // Let the class know wData is ready for use.
 }
Exemplo n.º 4
0
* Updated: 12/26/15
* By: Mike Rogers
* Notes
* Generic dashboard for displaying time and weather.
* 1.1 Implementing basic MVC style separation of business logic from view.
*****************************/
//include files
include_once "weather.php";
include_once "time.php";
include_once "getStocks.php";
include_once "navbar.php";
//DEBUG MODE
// Report all PHP errors (see changelog)
error_reporting(E_ALL);
//pull in the weather class
$weather = new weather();
$weatherWidget = $weather->weatherWidgetHTML();
$currentWeather = $weather->todaysWeather();
$tomorrowsWeather = $weather->tomorrowsWeather();
//extract the stocks
$stocks = new stockPrices();
$currentPrices = $stocks->getStocksDiv();
//pull in the time object and provide weather info
$time = new Time();
$welcomeWidget = $time->welcomeWidget($currentWeather, $tomorrowsWeather);
$timeNatLangWidget = $time->timeNaturalLanguage(1);
$wallpaperOverride = $time->wallpaperCss();
//import the navbar
$navObj = new NavBar();
$navBar = $navObj->generateMenu('home');
?>
Exemplo n.º 5
0
 public function execute($_options = array())
 {
     $eqLogic_weather = weather::byId($this->eqLogic_id);
     $weather = $eqLogic_weather->getWeatherArea();
     if (!is_array($weather)) {
         return false;
     }
     if ($this->getConfiguration('day') == -1) {
         if ($this->getConfiguration('data') == 'condition') {
             return $weather['condition']['text'];
         }
         if ($this->getConfiguration('data') == 'temp') {
             return $weather['condition']['temperature'];
         }
         if ($this->getConfiguration('data') == 'humidity') {
             return $weather['atmosphere']['humidity'];
         }
         if ($this->getConfiguration('data') == 'pressure') {
             return $weather['atmosphere']['pressure'];
         }
         if ($this->getConfiguration('data') == 'wind_speed') {
             return $weather['wind']['speed'];
         }
         if ($this->getConfiguration('data') == 'wind_direction') {
             return $weather['wind']['direction'];
         }
         if ($this->getConfiguration('data') == 'sunrise') {
             return $weather['astronomy']['sunrise'];
         }
         if ($this->getConfiguration('data') == 'sunset') {
             return $weather['astronomy']['sunset'];
         }
     }
     if ($this->getConfiguration('data') == 'condition') {
         return $weather['forecast'][$this->getConfiguration('day')]['condition'];
     }
     if ($this->getConfiguration('data') == 'low') {
         return $weather['forecast'][$this->getConfiguration('day')]['low_temperature'];
     }
     if ($this->getConfiguration('data') == 'high') {
         return $weather['forecast'][$this->getConfiguration('day')]['high_temperature'];
     }
     return false;
 }
Exemplo n.º 6
0
 * Jeedom is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Jeedom. If not, see <http://www.gnu.org/licenses/>.
 */
try {
    require_once dirname(__FILE__) . '/../../../../core/php/core.inc.php';
    include_file('core', 'authentification', 'php');
    if (!isConnect('admin')) {
        throw new Exception(__('401 - Accès non autorisé', __FILE__));
    }
    if (init('action') == 'getWeather') {
        $weather = weather::byId(init('id'));
        if (!is_object($weather)) {
            throw new Exception(__('Weather inconnu verifié l\'id', __FILE__));
        }
        $return = utils::o2a($weather);
        $return['cmd'] = array();
        foreach ($weather->getCmd() as $cmd) {
            $cmd_info = utils::o2a($cmd);
            $cmd_info['value'] = $cmd->execCmd(null, 0);
            $return['cmd'][] = $cmd_info;
        }
        ajax::success($return);
    }
    throw new Exception(__('Aucune methode correspondante à : ', __FILE__) . init('action'));
    /*     * *********Catch exeption*************** */
} catch (Exception $e) {
Exemplo n.º 7
0
 public function execute($_options = array())
 {
     if ($this->getLogicalId() == 'refresh') {
         weather::cron30($this->getEqLogic_id());
     } else {
         $eqLogic_weather = $this->getEqLogic();
         $weather = $eqLogic_weather->getWeatherFromYahooXml();
         if (!is_array($weather)) {
             sleep(1);
             $weather = $eqLogic_weather->getWeatherFromYahooXml();
             if (!is_array($weather)) {
                 return false;
             }
         }
         if ($this->getConfiguration('day') == -1) {
             if ($this->getConfiguration('data') == 'condition') {
                 return $weather['condition']['text'];
             }
             if ($this->getConfiguration('data') == 'temp') {
                 return $weather['condition']['temperature'];
             }
             if ($this->getConfiguration('data') == 'humidity') {
                 return $weather['atmosphere']['humidity'];
             }
             if ($this->getConfiguration('data') == 'pressure') {
                 return $weather['atmosphere']['pressure'];
             }
             if ($this->getConfiguration('data') == 'wind_speed') {
                 return $weather['wind']['speed'];
             }
             if ($this->getConfiguration('data') == 'wind_direction') {
                 return $weather['wind']['direction'];
             }
             if ($this->getConfiguration('data') == 'sunrise') {
                 return $weather['astronomy']['sunrise'];
             }
             if ($this->getConfiguration('data') == 'sunset') {
                 return $weather['astronomy']['sunset'];
             }
         }
         if ($this->getConfiguration('data') == 'condition') {
             return $weather['forecast'][$this->getConfiguration('day')]['condition'];
         }
         if ($this->getConfiguration('data') == 'low') {
             return $weather['forecast'][$this->getConfiguration('day')]['low_temperature'];
         }
         if ($this->getConfiguration('data') == 'high') {
             return $weather['forecast'][$this->getConfiguration('day')]['high_temperature'];
         }
         return false;
     }
 }
Exemplo n.º 8
0
                    			<div id="dataReturn_table" style="display: none; "></div>
                                <?php 
//require_once('assetModelling/fileUploader.html');
?>
                			</div>
                		</td>
            		</tr>
        		</table>
    	    </div>
            
           
    	<br /><br />
        </div>
        &copy; Copyright Conservation Resource Solutions, Inc. All rights reserved. Site Design by <a href="http://www.rvadv.com" target="_blank">Rearview</a>. 
    </div>
<?php 
//$mdrUser->preDebugger($_SESSION['UserObject']->PointChannels()->participationTypeList());
//$mdrUser->preDebugger($_POST);
//$mdrUser->preDebugger($_COOKIE['dsn']);
//$mdrUser->preDebugger($_SESSION);
?>

</body>
<?php 
echo $includesFoot;
if (!empty($_SESSION['iemsID'])) {
    require_once 'includes/weather.inc.php';
    $weather = new weather();
    echo "\n\t\t<script type=\"text/javascript\">\n        \n\t\t\$('weatherReturn_res').setProperty('html','" . $weather->Load($zipcode) . "');\n\n\t\t</script>\n\t";
}
echo '<!-- end page | time to render: ' . (microtime(true) - $pageStartTime) . '-->';
<?php

if (isset($_POST['apa']) && $_POST['apa'] != "") {
    include 'modules/model/class.weather.php';
    $data = new weather();
    switch ($_POST['apa']) {
        case "get-cuaca":
            $collect = array();
            if (isset($_POST['tglAwal']) && $_POST['tglAwal'] != "" && isset($_POST['tglAkhir']) && $_POST['tglAkhir'] != "") {
                if ($query = $data->get_weather($_POST['tglAwal'], $_POST['tglAkhir'], "%")) {
                    while ($rs = $query->fetch_array()) {
                        if ($rs["event"] == "1") {
                            $event = "Cerah";
                        } elseif ($rs["event"] == "2") {
                            $event = "Hujan";
                        } elseif ($rs["event"] == "3") {
                            $event = "Berawan / Badai Petir";
                        } elseif ($rs["event"] == "4") {
                            $event = "Hujan Disertai Badai Petir";
                        } else {
                            $event = "Tidak Diketahui";
                        }
                        $detail = array();
                        array_push($detail, $rs["date"]);
                        array_push($detail, $event);
                        array_push($detail, "<button type='button' class='btn btn-sm btn-primary' id='btn-show-detail' data-id='" . $rs['id'] . "'>\n\t\t\t\t\t\t\t\t\t\t<i class='fa fa-eye'></i></button>\n\t\t\t\t\t\t\t\t\t\t<button type='button' class='btn btn-sm btn-danger' id='btn-hapus-data' data-id='" . $rs['id'] . "'>\n\t\t\t\t\t\t\t\t\t\t<i class='fa fa-trash-o'></i></button>");
                        array_push($collect, $detail);
                        unset($detail);
                    }
                }
            }
Exemplo n.º 10
0
    if (isset($_ENV["TMP"])) {
        $cachedir = $_ENV["TMP"];
    } else {
        if (isset($_ENV["TMPDIR"])) {
            $cachedir = $_ENV["TMPDIR"];
        } else {
            // Default Cache Directory
            $cachedir = "/tmp";
        }
    }
}
$cachedir = str_replace('\\\\', '/', $cachedir);
if (substr($cachedir, -1) != '/') {
    $cachedir .= '/';
}
$weather_current = new weather($userzip, 600, "C", $cachedir);
// Parse the weather object via cached
// This checks if there's an valid cache object allready. if yes
// it takes the local object data, what's much FASTER!!! if it
// is expired, it refreshes automatically from rss online!
$weather_current->parsecached();
// => RECOMMENDED!
// allway refreshes from rss online. NOT SO FAST.
//$weather_current->parse(); // => NOT recommended!
// -------------------
// OUTPUT
// -------------------
// VARIOUS
$day = 0;
$city_current = $weather_current->forecast['CITY'];
// Santiago
Exemplo n.º 11
0
$timeout = 3 * 60 * 60;
// 3 hours
if (isset($_ENV["TEMP"])) {
    $cachedir = $_ENV["TEMP"];
} else {
    if (isset($_ENV["TMP"])) {
        $cachedir = $_ENV["TMP"];
    } else {
        if (isset($_ENV["TMPDIR"])) {
            $cachedir = $_ENV["TMPDIR"];
        } else {
            // Default Cache Directory
            $cachedir = "/tmp";
        }
    }
}
$cachedir = str_replace('\\\\', '/', $cachedir);
if (substr($cachedir, -1) != '/') {
    $cachedir .= '/';
}
$weather_location = new weather("USIL0070", 3600, "F", $cachedir);
// <-- Change this for different weather location
// Parse the weather object via cached
// This checks if there's an valid cache object allready. if yes
// it takes the local object data, what's much FASTER!!! if it
// is expired, it refreshes automatically from rss online!
// $weather_location->parsecached(); // => RECOMMENDED!
// allway refreshes from rss online. NOT AS FAST. (I DON"T CARE! I'm refreshing the data every 5min, it'll be ok if it takes a few extra mill)
$weather_location->parse();
// => NOT recommended!
echo json_encode($weather_location->forecast);
Exemplo n.º 12
0
if (!isset($_SESSION)) {
    // print ("Starting Session SaveFLower<br><br>");
    session_start();
}
if (isset($_SESSION)) {
    if (isset($_SESSION['current_user'])) {
        $user = $_SESSION['current_user'];
    }
}
// to see what is defined and included use this:
// debug_print_backtrace();
$php_errormsg = null;
$Plant = new Plant();
$Soil = new soil();
$Location = new Location();
$Weather = new weather();
if (isset($_GET['uid'])) {
    $Plant->setPlantUser($_GET['uid']);
} else {
    $php_errormsg = "Missing UserID. ";
}
if (isset($_GET['PlantName'])) {
    $Plant->setPlantName($_GET['PlantName']);
} else {
    $php_errormsg = $php_errormsg . "Missing Plant Name.<br> ";
}
if (isset($_GET['OnSite'])) {
    $Plant->setPlantEnteredOnSite($_GET['OnSite']);
} else {
    $php_errormsg = $php_errormsg . "Missing On Site.<br> ";
}
Exemplo n.º 13
0
    .city{color: red}
    .city span{font-weight: bold;}
    </style>
</head>
<body>
    <?php 
header("content-type:text/html;charset=utf-8");
include_once "./weather.class.php";
$text = $_REQUEST['location_c'];
echo '<div class="waterbox">';
echo '<div class="citybox">';
echo '<p class="city">你查询的城市是:<span>&nbsp;&nbsp;' . $text . '</span></p>';
echo '<br/>';
$appkey = '902b689cae6ccba5d0a659a50a980688';
//您申请的天气查询appkey
$weather = new weather($appkey);
$cityWeatherResult = $weather->getWeather($text);
if ($cityWeatherResult['error_code'] == 0) {
    //以下可根据实际业务需求,自行改写
    //////////////////////////////////////////////////////////////////////
    $data = $cityWeatherResult['result'];
    echo "=======当前天气实况=======<br/>";
    echo "温度:" . $data['sk']['temp'] . "&nbsp;&nbsp;&nbsp;&nbsp;";
    echo "风向:" . $data['sk']['wind_direction'] . "&nbsp;&nbsp;&nbsp;&nbsp;(" . $data['sk']['wind_strength'] . ")";
    echo "湿度:" . $data['sk']['humidity'] . "&nbsp;&nbsp;&nbsp;&nbsp;";
    echo "<br/><br/>";
    echo "=======未来几天天气预报=======<br/>";
    foreach ($data['future'] as $wkey => $f) {
        echo "日期:" . $f['date'] . " " . $f['week'] . " " . $f['weather'] . " " . $f['temperature'] . "<br/>";
    }
    echo "<br/><br/>";
Exemplo n.º 14
0
    if (isset($_ENV["TMP"])) {
        $cachedir = $_ENV["TMP"];
    } else {
        if (isset($_ENV["TMPDIR"])) {
            $cachedir = $_ENV["TMPDIR"];
        } else {
            $cachedir = "/tmp";
        }
    }
}
$cachedir = str_replace('\\\\', '/', $cachedir);
if (substr($cachedir, -1) != '/') {
    $cachedir .= '/';
}
foreach ($yahooLocCodes as $locCode) {
    $weather = new weather($locCode, $timeout, $units, $cachedir);
    $weather->parsecached();
    print "<tr>";
    $attr = substr($locCode, 0, 2) == $country ? "style='background-color:yellow;'" : "";
    print XmlCell($weather->forecast['CITY'], $attr);
    print XmlCell($weather->forecast['PUBDATE']);
    print XmlCell($weather->forecast['SUNRISE']);
    print XmlCell($weather->forecast['SUNSET']);
    @(print XmlCell($weather->forecast['CURRENT']['TEXT']));
    @(print tempCell($weather->forecast['CURRENT']['TEMP']));
    print tempCell($weather->forecast[0]['LOW']);
    print tempCell($weather->forecast[0]['HIGH']);
    print XmlCell($weather->forecast[0]['TEXT']);
    print XmlCell($weather->source);
    print "</tr>";
}
Exemplo n.º 15
0
    print ("<br>AFter session print <br>");
    */
    if (isset($_SESSION['current_plant'])) {
        $Plant = $_SESSION['current_plant'];
    } else {
        $Plant = new Plant();
    }
    if (isset($_SESSION['current_location'])) {
        $Location = $_SESSION['current_location'];
    } else {
        $Location = new Location();
    }
    if (isset($_SESSION['current_weather'])) {
        $Weather = $_SESSION['current_weather'];
    } else {
        $Weather = new weather();
    }
}
$Soil = new soil();
$SoilList = $Soil->GetAllSoils();
$SoilMenu = new selectMenu();
$SoilMenu->setOptions($SoilList);
include_once 'include/header.php';
if (isset($php_errormsg)) {
    ?>
    <h1> Please correct the following errors: <?php 
    $php_errormsg;
    ?>
</h1>
<?php 
}