/**
  * Loads the current locale. It works so that it tries to fetch the parameter "lang" from the
  * request. If it's not available, then it will try to look for it in the session. If it is not
  * there either, it will try to guess the most prefered language according to what the User Agent 
  * included in the HTTP_ACCEPT_LANGUAGE string sent with the request. If none matches available 
  * languages we have to use the value of "default_locale" and display the default language.
  *
  * @private
  * @return Returns a reference to a Locale object
  */
 function &_loadLocale()
 {
     $requestLocale =& $this->_request->getValue("lang");
     $localeCode = "";
     $serverVars =& HttpVars::getServer();
     // check if there's something in the request...
     // if not, check the session or at least try to
     // guess the apropriate languege from the http_accept_lnaguage string
     if ($requestLocale) {
         // check if it's a valid one
         if (Locales::isValidLocale($requestLocale)) {
             $localeCode = $requestLocale;
         }
     } else {
         $sessionLocale =& SessionManager::getSessionValue("summaryLang");
         if ($sessionLocale) {
             $localeCode = $sessionLocale;
         } elseif ($this->_config->getValue("use_http_accept_language_detection", HTTP_ACCEPT_LANGUAGE_DETECTION) == 1) {
             $localeCode =& $this->_matchHttpAcceptLanguages($serverVars['HTTP_ACCEPT_LANGUAGE']);
         }
     }
     // check if the locale code is correct
     // and as a valid resort, use the default one if the locale ist not valid or 'false'
     if ($localeCode === false || !Locales::isValidLocale($localeCode)) {
         $localeCode = $this->_config->getValue("default_locale");
     }
     // now put whatever locale value back to the session
     SessionManager::setSessionValue("summaryLang", $localeCode);
     // load the correct locale
     $locale =& Locales::getLocale($localeCode);
     return $locale;
 }
 /**
  * returns true if a given url is using a subdomain or not. It works by comparing
  * the url with "base_url" from the plog_config table. If they match, then the incoming
  * url is *not* using subdomains. Otherwise, it will return true
  *
  * @param url If null, use $_SERVER["HTTP_HOST"]
  * @return true if the given url is subdomained or not
  * @static
  */
 function isSubdomainUrl($url = null)
 {
     // prepare the url
     if ($url == null) {
         $server = HttpVars::getServer();
         $urlObject = new Url("http://" . $server["HTTP_HOST"]);
     } else {
         $urlObject = new Url($url);
     }
     // and now get the base_url
     $config =& Config::getConfig();
     $baseUrlObject = new Url($config->getValue("base_url"));
     // and finally check if whether they match or not
     if ($urlObject->getHost() == $baseUrlObject->getHost()) {
         $isSubdomain = false;
     } else {
         $isSubdomain = true;
     }
     // return it...
     return $isSubdomain;
 }
 /**
  * Checks the given email address
  */
 function validate($value)
 {
     if (empty($value)) {
         $this->_setError(false);
         return true;
     }
     list($userName, $domain) = explode("@", $value);
     $connectAddress = $domain;
     if (!Dns::checkdnsrr($domain, "A")) {
         $this->_setError(ERROR_RULE_EMAIL_DNS_SERVER_UNREACHABLE);
         return false;
     }
     if (Dns::checkdnsrr($domain, "MX") && Dns::getmxrr($domain, $mxHosts)) {
         $connectAddress = $mxHosts[0];
     }
     if ($connect = fsockopen($connectAddress, 25)) {
         $out = fgets($connect, 1024);
         if (ereg("^220", $out)) {
             $server =& HttpVars::getServer();
             fputs($connect, "HELO " . $server["HTTP_HOST"] . "\r\n");
             $out = fgets($connect, 1024);
             fputs($connect, "MAIL FROM: <" . $value . ">\r\n");
             $from = fgets($connect, 1024);
             fputs($connect, "RCPT TO: <" . $value . ">\r\n");
             $to = fgets($connect, 1024);
             fputs($connect, "QUIT\r\n");
             fclose($connect);
             if (!ereg("^250", $from) || !ereg("^250", $to)) {
                 $this->_setError(ERROR_RULE_EMAIL_DNS_NOT_PERMITTED);
                 return false;
             }
         }
     } else {
         $this->_setError(ERROR_RULE_EMAIL_DNS_SERVER_UNREACHABLE);
         return false;
     }
     return true;
 }
示例#4
0
if (!defined("PLOG_CLASS_PATH")) {
    define("PLOG_CLASS_PATH", dirname(__FILE__) . "/");
}
include_once PLOG_CLASS_PATH . "class/config/config.class.php";
include_once PLOG_CLASS_PATH . "class/net/http/httpvars.class.php";
include_once PLOG_CLASS_PATH . "class/net/customurlhandler.class.php";
// get the configuration data
$config =& Config::getConfig();
// in order to maintain compatilibity with previous version, and the alternative
// format of search-engine friendly urls
if ($config->getValue("request_format_mode") == SEARCH_ENGINE_FRIENDLY_MODE) {
    include_once PLOG_CLASS_PATH . "error.php";
    die;
}
$server = HttpVars::getServer();
$requestParser = new CustomUrlHandler();
$requestParser->process($server["REQUEST_URI"]);
$vars = $requestParser->getVars();
$params = $requestParser->getParams();
$includeFile = $requestParser->getIncludeFile();
//
// fill in the request with the parameters we need
//
$vars["op"] = "op";
foreach ($vars as $key => $value) {
    if (is_array($params) && array_key_exists($key, $params) && $params["{$key}"] != "") {
        HttpVars::setRequestValue($vars["{$key}"], $params["{$key}"]);
    }
}
// and transfer execution to the main script
 /**
  * Returns the base URL of the script
  *
  * @return A string containing the base URL of the script
  * @static
  */
 function getBaseUrl()
 {
     $serverVars = HttpVars::getServer();
     if (!isset($serverVars['HTTPS']) || strtolower($serverVars['HTTPS']) != 'on') {
         $protocol = 'http://';
     } else {
         $protocol = 'https://';
     }
     $host = $serverVars["HTTP_HOST"];
     $scriptUrl = $serverVars["PHP_SELF"];
     return $protocol . $host . $scriptUrl;
 }