Exemplo n.º 1
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     // When 'phpweather/phpweather.php' is not installed then
     // PHPWEATHER_BASE_DIR will be undefined.
     if (!defined('PHPWEATHER_BASE_DIR')) {
         return $this->error(_("You have to define PHPWEATHER_BASE_DIR before use. (config/config.ini)"));
     }
     //early return
     require_once PHPWEATHER_BASE_DIR . '/output/pw_images.php';
     require_once PHPWEATHER_BASE_DIR . '/pw_utilities.php';
     extract($this->getArgs($argstr, $request));
     $html = HTML();
     $w = new phpweather();
     // Our weather object
     if (!empty($icao)) {
         /* We assign the ICAO to the weather object: */
         $w->set_icao($icao);
         if (!$w->get_country_code()) {
             /* The country code couldn't be resolved, so we
              * shouldn't use the ICAO: */
             trigger_error(sprintf(_("The ICAO '%s' wasn't recognized."), $icao), E_USER_NOTICE);
             $icao = '';
         }
     }
     if (!empty($icao)) {
         /* We check and correct the language if necessary: */
         //if (!in_array($language, array_keys($w->get_languages('text')))) {
         if (!in_array($language, array_keys(get_languages('text')))) {
             trigger_error(sprintf(_("%s does not know about the language '%s', using 'en' instead."), $this->getName(), $language), E_USER_NOTICE);
             $language = 'en';
         }
         $class = "pw_text_{$language}";
         require_once PHPWEATHER_BASE_DIR . "/output/{$class}.php";
         $t = new $class($w);
         $t->set_pref_units($units);
         $i = new pw_images($w);
         $i_temp = HTML::img(array('src' => $i->get_temp_image()));
         $i_wind = HTML::img(array('src' => $i->get_winddir_image()));
         $i_sky = HTML::img(array('src' => $i->get_sky_image()));
         $m = $t->print_pretty();
         $m_td = HTML::td(HTML::p(new RawXml($m)));
         $i_tr = HTML::tr();
         $i_tr->pushContent(HTML::td($i_temp));
         $i_tr->pushContent(HTML::td($i_wind));
         $i_table = HTML::table($i_tr);
         $i_table->pushContent(HTML::tr(HTML::td(array('colspan' => '2'), $i_sky)));
         $tr = HTML::tr();
         $tr->pushContent($m_td);
         $tr->pushContent(HTML::td($i_table));
         $html->pushContent(HTML::table($tr));
     }
     /* We make a menu if asked to, or if $icao is empty: */
     if ($menu || empty($icao)) {
         $form_arg = array('action' => $request->getURLtoSelf(), 'method' => 'get');
         /* The country box is always part of the menu: */
         $p1 = HTML::p(new RawXml(get_countries_select($w, $cc)));
         /* We want to save the language: */
         $p1->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'language', 'value' => $language)));
         /* And also the ICAO: */
         $p1->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'icao', 'value' => $icao)));
         $caption = empty($cc) ? _("Submit country") : _("Change country");
         $p1->pushContent(HTML::input(array('type' => 'submit', 'value' => $caption)));
         $html->pushContent(HTML::form($form_arg, $p1));
         if (!empty($cc)) {
             /* We have selected a country, now display a list with
              * the available stations in that country: */
             $p2 = HTML::p();
             /* We need the country code after the form is submitted: */
             $p2->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'cc', 'value' => $cc)));
             $p2->pushContent(new RawXml(get_stations_select($w, $cc, $icao)));
             $p2->pushContent(new RawXml(get_languages_select($language)));
             $p2->pushContent(HTML::input(array('type' => 'submit', 'value' => _("Submit location"))));
             $html->pushContent(HTML::form($form_arg, $p2));
         }
     }
     return $html;
 }
Exemplo n.º 2
0
 $row3 = MySQL_Fetch_Object($res3);
 if (!$row3) {
     continue;
 }
 $icao = $row3->icao;
 // if domain isn't in cache, continue with next contact
 if (!$icao) {
     continue;
 }
 // if icao for this domain isn't in cache, continue with next contact
 if (in_array($icao, $user_icao_cache)) {
     continue;
 }
 //metar data already sended from this icao
 $user_icao_cache[] = $icao;
 $weather->set_icao($icao);
 if (!$weather->get_metar()) {
     continue;
 }
 //there is no avaiable metar data
 $text = new $text_type($weather);
 $message = $text->print_pretty();
 //delete html tags from phpweather otuput
 $message = ereg_Replace("<[^>]*>", "", $message);
 //replace special chars in phpweather otuput
 $message = str_Replace("&nbsp;", " ", $message);
 $message = str_Replace("&deg;", "°", $message);
 $send_na = false;
 //successfully get data for user, not to need send n/a message
 /* construct FIFO command */
 $fifo_cmd = ":t_uac_from:" . $config->reply_fifo_filename . "\n" . "MESSAGE\n" . $config->metar_from_sip_uri . "\n" . "sip:" . $row->username . "@" . $config->default_domain . "\n" . "p-version: " . $config->psignature . "\n" . "Contact: " . $config->web_contact . "\n" . "Content-Type: text/plain; charset=UTF-8\n\n" . str_Replace("\n.\n", "\n. \n", $message) . "\n.\n\n";