Esempio n. 1
0
function follow_http_redirects($url, $redirects = 5)
{
    $result = false;
    $referer = null;
    while ($redirects-- >= 0) {
        list($protocol, , $hostname, $path) = explode("/", $url, 4);
        if ($protocol == "http:") {
            $http = new HTTP($hostname);
        } else {
            if ($protocol == "https:") {
                $http = new HTTPS($hostname);
            } else {
                break;
            }
        }
        if ($referer != null) {
            $http->add_header("Referer", $referer);
        }
        $result = $http->GET("/" . $path);
        unset($http);
        $referer = $url;
        if ($result === false) {
            break;
        } else {
            if ($result["status"] != 301 && $result["status"] != 302) {
                break;
            } else {
                if (($url = $result["headers"]["location"]) == "") {
                    break;
                }
            }
        }
    }
    return $result;
}
Esempio n. 2
0
 public function __construct($application, $api_keys, $provider_key = null)
 {
     $this->application = $this->truncate($application, 256);
     if (is_array($api_keys) == false) {
         $this->api_keys = array($api_keys);
     } else {
         $this->api_keys = $api_keys;
     }
     $this->provider_key = $provider_key;
     parent::__construct($this->server);
 }
Esempio n. 3
0
 public function render()
 {
     if (!$this->_image) {
         $this->_image = array('src' => HTTPS::is_https() ? HTTPS::convert_path(Config::get('global', 'header_home_button')) : Config::get('global', 'header_home_button'), 'alt' => Config::get('global', 'header_home_button_alt'));
     }
     $image = HTML_Decorator::tag('img', false, $this->_image)->render();
     $home_button = HTML_Decorator::tag('a', $image, array('href' => HTTPS::is_https() ? HTTPS::convert_path(Config::get('global', 'site_url')) : Config::get('global', 'site_url')))->render();
     if ($this->_title_path) {
         $title = $this->_title ? HTML_Decorator::tag('a', $this->_title, array('href' => $this->_title_path)) : false;
     } else {
         $title = $this->_title ? $this->_title : '';
     }
     $title_span = $title ? HTML_Decorator::tag('span', $title)->render() : '';
     $this->set_param('id', 'header');
     $this->add_inner_front($home_button . $title_span);
     return parent::render();
 }
Esempio n. 4
0
 public function render()
 {
     $handler_css = $this->_handler_css ? $this->_handler_css : Config::get('global', 'site_assets_url') . '/css.php?';
     foreach ($this->_handler_css_params as $key => $val) {
         $handler_css .= is_int($key) ? $val . '&' : $key . '=' . $val . '&';
     }
     $handler_css = substr($handler_css, 0, strlen($handler_css) - 1);
     $handler_js = $this->_handler_js ? $this->_handler_js : Config::get('global', 'site_assets_url') . '/js.php?';
     foreach ($this->_handler_js_params as $key => $val) {
         $handler_js .= is_int($key) ? $val . '&' : $key . '=' . $val . '&';
     }
     $handler_js = substr($handler_js, 0, strlen($handler_js) - 1);
     $this->add_inner_tag_front('meta', false, array('name' => 'viewport', 'content' => 'height=device-height,width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no'));
     $this->add_inner_tag_front('script', null, array('type' => 'text/javascript', 'src' => HTTPS::is_https() ? HTTPS::convert_path($handler_js) : $handler_js));
     $this->add_inner_tag_front('link', false, array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => HTTPS::is_https() ? HTTPS::convert_path($handler_css) : $handler_css, 'media' => 'screen'));
     $this->add_inner_tag_front('title', $this->_title);
     $charset = Config::get('global', 'charset');
     if ($charset !== false) {
         $this->add_inner_tag_front('meta', false, array('charset' => $charset));
     }
     return parent::render();
 }
Esempio n. 5
0
}
?>

var mwf=new function(){};

mwf.site=new function(){

this.root = '<?php 
echo HTTPS::is_https() ? HTTPS::convert_path(Config::get('global', 'site_url')) : Config::get('global', 'site_url');
?>
';

this.asset = new function(){

this.root = '<?php 
echo HTTPS::is_https() ? HTTPS::convert_path(Config::get('global', 'site_assets_url')) : Config::get('global', 'site_assets_url');
?>
';

};

this.cookie = new function(){

this.prefix = '<?php 
echo Config::get('global', 'cookie_prefix');
?>
';
this.domain = <?php 
echo '\'' . $domain_var . '\'';
?>
;
Esempio n. 6
0
 public function execute()
 {
     if ($this->page->ajax_request) {
         if ($this->page->pathinfo[1] == null) {
             $this->output->add_tag("max_alert_count", count($this->alerts));
             $this->output->add_tag("page_refresh", $this->settings->dashboard_page_refresh);
         } else {
             $this->show_alert($this->page->pathinfo[1]);
         }
         return;
     }
     if (isset($_SESSION["latest_hiawatha_version"]) == false) {
         $hiawatha_website = new HTTPS("www.hiawatha-webserver.org");
         if (($result = $hiawatha_website->GET("/latest")) !== false) {
             $_SESSION["latest_hiawatha_version"] = $result["body"];
         }
     }
     if (isset($_SESSION["latest_mbedtls_version"]) == false) {
         $mbedtls_website = new HTTPS("tls.mbed.org");
         if (($result = $mbedtls_website->GET("/download/latest-stable-version")) !== false) {
             $_SESSION["latest_mbedtls_version"] = $result["body"];
         }
     }
     /* Webserver
      */
     if (($webservers = $this->model->get_webservers()) === false) {
         return;
     }
     $webservers_offline = false;
     foreach ($webservers as $webserver) {
         $webserver["address"] = ($webserver["tls"] == 0 ? "http" : "https") . "://" . $webserver["ip_address"];
         if ($webserver["tls"] == 0 && $webserver["port"] != 80 || $webserver["tls"] == 1 && $webserver["port"] != 443) {
             $webserver["address"] .= ":" . $webserver["port"];
         }
         $webserver["address"] .= "/";
         if ($webserver["active"]) {
             if ($webserver["errors"] == 0) {
                 $webserver["status"] = "online";
             } else {
                 $webserver["status"] = "offline";
                 $webservers_offline = true;
             }
         }
         $webserver["tls"] = show_boolean($webserver["tls"]);
         $webserver["active"] = show_boolean($webserver["active"]);
         if ($webserver["version"] != "") {
             $parts = explode(",", $webserver["version"]);
             list(, $version) = explode("v", $parts[0], 2);
             $comparison = version_compare($version, $_SESSION["latest_hiawatha_version"], ">=");
             $webserver["uptodate"] = show_boolean($comparison);
             foreach ($parts as $part) {
                 if (in_array(substr(ltrim($part), 0, 3), array("TLS", "SSL"))) {
                     $version = trim(substr($part, 4), " ()");
                     if (version_compare($version, $_SESSION["latest_mbedtls_version"], "<")) {
                         $webserver["uptodate"] .= " (mbed TLS out of date)";
                     }
                 }
             }
         }
         $this->output->record($webserver, "webserver");
     }
     if ($webservers_offline) {
         $this->output->add_system_message("Warning, one or more webservers are unavailable!");
     }
     /* Alerts
      */
     $this->output->add_javascript("jquery/jquery-ui.js");
     $this->output->add_javascript("dashboard.js");
     $this->output->add_css("jquery/jquery-ui.css");
     $this->output->add_tag("threshold_change", $this->settings->dashboard_threshold_change);
     $this->output->add_tag("threshold_value", $this->settings->dashboard_threshold_value);
     $this->output->add_tag("page_refresh", $this->settings->dashboard_page_refresh);
 }
Esempio n. 7
0
 /**
  * Echo a call to mwf.util.importJS such that a new script tag is added to
  * the DOM for $url. Returns true if the import is successful, or false
  * if the file has already been loaded. The $allow_multiple boolean, if
  * set true, allows one to make the same call multiple times.
  * 
  * @param string $url
  * @param bool $allow_multiple
  * @return bool 
  */
 public static function import_external($url, $allow_multiple = false)
 {
     /**
      * Return false if $url has already been loaded and $allow_multiple
      * is false, thus not allowing for multiple loads of the same file.
      */
     if (in_array($url, self::$_external_loaded) && !$allow_multiple) {
         return false;
     }
     /**
      * Output a call to mwf.util.importJS and return true after storing
      * the $url under $_external_loaded to prevent multiple inclusion.
      */
     echo 'mwf.util.importJS(\'' . (HTTPS::is_https() ? HTTPS::convert_path($url) : $url) . '\');';
     self::$_external_loaded[] = $url;
     return true;
 }