示例#1
0
 static function load_request($allow)
 {
     $uri = getRequestURI();
     $parts = explode('?', $uri);
     $uri = $parts[0];
     $path = ltrim(substr($uri, strlen(WEBPATH) + 1), '/');
     if (empty($path)) {
         return $allow;
     } else {
         $rest = strpos($path, '/');
         if ($rest === false) {
             if (strpos($path, '?') === 0) {
                 // only a parameter string
                 return $allow;
             }
             $l = $path;
         } else {
             $l = substr($path, 0, $rest);
         }
     }
     $locale = validateLocale($l, 'seo_locale');
     if ($locale) {
         // set the language cookie and redirect to the "base" url
         zp_setCookie('dynamic_locale', $locale);
         $uri = pathurlencode(preg_replace('|/' . $l . '[/$]|', '/', $uri));
         if (isset($parts[1])) {
             $uri .= '?' . $parts[1];
         }
         header("HTTP/1.0 302 Found");
         header("Status: 302 Found");
         header('Location: ' . $uri);
         exitZP();
     }
     return $allow;
 }
示例#2
0
 function getOptionsSupported()
 {
     $host = $_SERVER['HTTP_HOST'];
     $matches = explode('.', $host);
     if (validateLocale($matches[0], 'Dynamic Locale')) {
         array_shift($matches);
         $host = implode('.', $matches);
     }
     $localdesc = '<p>' . sprintf(gettext('If checked links to the alternative languages will be in the form <code><em>language</em>.%1$s</code> where <code><em>language</em></code> is the language code, e.g. <code><em>fr</em></code> for French.'), $host) . '</p>';
     $localdesc .= '<p>' . sprintf(gettext('This requires that you have created the appropriate subdomains pointing to your installation. That is <code>fr.%1$s</code> must point to the same location as <code>%1$s</code>. (Some providers will automatically redirect undefined subdomains to the main domain. If your provider does this, no subdomain creation is needed.)'), $host . WEBPATH) . '</p>';
     $options = array(gettext('Gallery index page') => array('key' => 'sitemap_galleryindex', 'type' => OPTION_TYPE_TEXTBOX, 'order' => 11, 'multilingual' => false, 'desc' => gettext('If your theme does not use the theme index.php page as the gallery index, enter the name of the page here. In the Zenpage theme for example this could be gallery.php. In that case you enter "gallery". If this is not empty the index.php sitemap is not generated.')), gettext('Album date') => array('key' => 'sitemap_lastmod_albums', 'type' => OPTION_TYPE_SELECTOR, 'order' => 0, 'selections' => array(gettext("date") => "date", gettext("mtime") => "mtime"), 'desc' => gettext('Field to use for the last modification date of albums.')), gettext('Image date') => array('key' => 'sitemap_lastmod_images', 'type' => OPTION_TYPE_SELECTOR, 'order' => 1, 'selections' => array(gettext("date") => "date", gettext("mtime") => "mtime"), 'desc' => gettext('Field to use for the last modification date of images.')), gettext('Change frequency - ZenPhoto20 index') => array('key' => 'sitemap_changefreq_index', 'type' => OPTION_TYPE_SELECTOR, 'order' => 2, 'selections' => array(gettext("always") => "always", gettext("hourly") => "hourly", gettext("daily") => "daily", gettext("weekly") => "weekly", gettext("monthly") => "monthly", gettext("yearly") => "yearly", gettext("never") => "never"), 'desc' => ''), gettext('Change frequency - albums') => array('key' => 'sitemap_changefreq_albums', 'type' => OPTION_TYPE_SELECTOR, 'order' => 3, 'selections' => array(gettext("always") => "always", gettext("hourly") => "hourly", gettext("daily") => "daily", gettext("weekly") => "weekly", gettext("monthly") => "monthly", gettext("yearly") => "yearly", gettext("never") => "never"), 'desc' => ''), gettext('Change frequency - images') => array('key' => 'sitemap_changefreq_images', 'type' => OPTION_TYPE_SELECTOR, 'order' => 4, 'selections' => array(gettext("always") => "always", gettext("hourly") => "hourly", gettext("daily") => "daily", gettext("weekly") => "weekly", gettext("monthly") => "monthly", gettext("yearly") => "yearly", gettext("never") => "never"), 'desc' => ''), gettext('Change frequency - Zenpage pages') => array('key' => 'sitemap_changefreq_pages', 'type' => OPTION_TYPE_SELECTOR, 'order' => 5, 'selections' => array(gettext("always") => "always", gettext("hourly") => "hourly", gettext("daily") => "daily", gettext("weekly") => "weekly", gettext("monthly") => "monthly", gettext("yearly") => "yearly", gettext("never") => "never"), 'desc' => ''), gettext('Change frequency - Zenpage news index') => array('key' => 'sitemap_changefreq_newsindex', 'type' => OPTION_TYPE_SELECTOR, 'order' => 6, 'selections' => array(gettext("always") => "always", gettext("hourly") => "hourly", gettext("daily") => "daily", gettext("weekly") => "weekly", gettext("monthly") => "monthly", gettext("yearly") => "yearly", gettext("never") => "never"), 'desc' => ''), gettext('Change frequency: Zenpage news articles') => array('key' => 'sitemap_changefreq_news', 'type' => OPTION_TYPE_SELECTOR, 'order' => 7, 'selections' => array(gettext("always") => "always", gettext("hourly") => "hourly", gettext("daily") => "daily", gettext("weekly") => "weekly", gettext("monthly") => "monthly", gettext("yearly") => "yearly", gettext("never") => "never"), 'desc' => ''), gettext('Change frequency - Zenpage news categories') => array('key' => 'sitemap_changefreq_newscats', 'type' => OPTION_TYPE_SELECTOR, 'order' => 8, 'selections' => array(gettext("always") => "always", gettext("hourly") => "hourly", gettext("daily") => "daily", gettext("weekly") => "weekly", gettext("monthly") => "monthly", gettext("yearly") => "yearly", gettext("never") => "never"), 'desc' => ''), gettext('Enable Google image and video extension') => array('key' => 'sitemap_google', 'type' => OPTION_TYPE_CHECKBOX, 'order' => 9, 'desc' => gettext('If checked, the XML output file will be formatted using the Google XML image and video extensions where applicable.') . '<p class="notebox">' . gettext('<strong>Note:</strong> Other search engines (Yahoo, Bing) might not be able to read your sitemap. Also the Google extensions cover only image and video formats. If you use custom file types that are not covered by Zenphoto standard plugins or types like .mp3, .txt and .html you should probably not use this or modify the plugin. Also, if your site is really huge think about if you really need this setting as the creation may cause extra workload of your server and result in timeouts') . '</p>'), gettext('Google image and video extension: Link full image ') => array('key' => 'sitemap_google_fullimage', 'type' => OPTION_TYPE_CHECKBOX, 'order' => 10, 'desc' => gettext('If checked, the original full image is referenced instead of the sized images in the cache. For image formats only.')), gettext('Google - URL to image license') => array('key' => 'sitemap_license', 'type' => OPTION_TYPE_TEXTBOX, 'order' => 12, 'multilingual' => true, 'desc' => gettext('Optional. Used only if the Google extension is checked. Must be an absolute URL address of the form: ' . FULLWEBPATH . '/license.html')), gettext('Sitemap processing chunk') => array('key' => 'sitemap_processing_chunk', 'type' => OPTION_TYPE_NUMBER, 'order' => 13, 'desc' => gettext('The number of albums that will be processed for each sitemap file. Lower this value if you get script timeouts when creating the files.')), gettext('Use subdomains') . '*' => array('key' => 'dynamic_locale_subdomain', 'type' => OPTION_TYPE_CHECKBOX, 'order' => 14, 'desc' => $localdesc));
     $options['note'] = array('key' => 'sitemap_locale_type', 'type' => OPTION_TYPE_NOTE, 'order' => 15, 'desc' => gettext('<p class="notebox">*<strong>Note:</strong> The setting of this option is shared with other plugins.</p>'));
     return $options;
 }
示例#3
0
function filterLocale_load_request($allow)
{
    $uri = urldecode(sanitize($_SERVER['REQUEST_URI'], 0));
    $path = substr($uri, strlen(WEBPATH) + 1);
    $path = str_replace('\\', '/', $path);
    if (substr($path, 0, 1) == '/') {
        $path = substr($path, 1);
    }
    if (empty($path)) {
        return $allow;
    } else {
        $rest = strpos($path, '/');
        if ($rest === false) {
            if (strpos($path, '?') === 0) {
                // only a parameter string
                return $allow;
            }
            $l = $path;
        } else {
            $l = substr($path, 0, $rest);
        }
    }
    $locale = validateLocale($l, 'seo_locale');
    if ($locale) {
        // set the language cookie and redirect to the "base" url
        zp_setCookie('dynamic_locale', $locale);
        if (substr($path, -1, 1) == '/') {
            $path = substr($path, 0, strlen($path) - 1);
        }
        $path = FULLWEBPATH . substr($path, strlen($l));
        header("HTTP/1.0 302 Found");
        header("Status: 302 Found");
        header('Location: ' . $path);
        exit;
    }
    return $allow;
}
示例#4
0
/**
 * Sets the locale, etc. to the zenphoto domain details.
 * Returns the result of setupCurrentLocale()
 *
 */
function setMainDomain()
{
    global $_zp_current_admin_obj, $_zp_current_locale;
    if (DEBUG_LOCALE) {
        debugLogBackTrace("setMainDomain()");
    }
    if (isset($_REQUEST['locale'])) {
        $_zp_current_locale = validateLocale(sanitize($_REQUEST['locale']), isset($_POST['locale']) ? 'POST' : 'URI string');
        if ($_zp_current_locale) {
            zp_setCookie('dynamic_locale', $_zp_current_locale);
        } else {
            zp_clearCookie('dynamic_locale');
        }
        if (DEBUG_LOCALE) {
            debugLog("dynamic_locale from URL: " . sanitize($_REQUEST['locale']) . "=>{$_zp_current_locale}");
        }
    } else {
        $matches = explode('.', @$_SERVER['HTTP_HOST']);
        $_zp_current_locale = validateLocale($matches[0], 'HTTP_HOST');
        if ($_zp_current_locale && zp_getCookie('dynamic_locale')) {
            zp_clearCookie('dynamic_locale');
        }
        if (DEBUG_LOCALE) {
            debugLog("dynamic_locale from HTTP_HOST: " . sanitize($matches[0]) . "=>{$_zp_current_locale}");
        }
    }
    if (!$_zp_current_locale && is_object($_zp_current_admin_obj)) {
        $_zp_current_locale = $_zp_current_admin_obj->getLanguage();
        if (DEBUG_LOCALE) {
            debugLog("locale from user: "******"locale from option: " . $localeOption . '; dynamic locale=' . $_zp_current_locale);
        }
        if (empty($localeOption) && empty($_zp_current_locale)) {
            // if one is not set, see if there is a match from 'HTTP_ACCEPT_LANGUAGE'
            $languageSupport = generateLanguageList();
            $userLang = parseHttpAcceptLanguage();
            foreach ($userLang as $lang) {
                $l = strtoupper($lang['fullcode']);
                $_zp_current_locale = validateLocale($l, 'HTTP Accept Language');
                if ($_zp_current_locale) {
                    break;
                }
            }
        } else {
            if (empty($_zp_current_locale)) {
                $_zp_current_locale = $localeOption;
            }
        }
    }
    if (empty($_zp_current_locale)) {
        // return "default" language, English if allowed, otherwise whatever is the "first" allowed language
        $languageSupport = generateLanguageList();
        if (defined('BASE_LOCALE')) {
            $loc = BASE_LOCALE;
        } else {
            $loc = 'en_US';
        }
        if (empty($languageSupport) || in_array($loc, $languageSupport)) {
            $_zp_current_locale = $loc;
        } else {
            $_zp_current_locale = array_shift($languageSupport);
        }
        if (DEBUG_LOCALE) {
            debugLog("locale from language list: " . $_zp_current_locale);
        }
    } else {
        setOption('locale', $_zp_current_locale, false);
    }
    if (DEBUG_LOCALE) {
        debugLog("getUserLocale Returning locale: " . $_zp_current_locale);
    }
    return setupCurrentLocale($_zp_current_locale);
}
示例#5
0
 static function fullHostPath($lang)
 {
     global $_locale_Subdomains;
     $host = $_SERVER['HTTP_HOST'];
     $matches = explode('.', $host);
     if (validateLocale($matches[0], 'Dynamic Locale')) {
         array_shift($matches);
         $host = implode('.', $matches);
     }
     if ($l = $_locale_Subdomains[$lang]) {
         $host = $l . '.' . $host;
     }
     if (SERVER_PROTOCOL == 'https') {
         $host = 'https://' . $host;
     } else {
         $host = 'http://' . $host;
     }
     return $host;
 }
示例#6
0
include '../etc/utils.php';
include '../etc/constants.php';
require_once '../etc/ext/MobileDetect/Mobile_Detect.php';
init_mysql();
// Set locale and validate
$locale = retrieve_from_get($proto_locale, false);
if (is_null($locale)) {
    if (isset($_COOKIE[$proto_locale])) {
        $locale = validateLocale($_COOKIE[$proto_locale]);
    } else {
        $locale = $proto_locale_english;
    }
} else {
    // Locale is enforced, save it to cookie.
    $locale = validateLocale($locale);
    setcookie($proto_locale, $locale, time() + $cookie_expiry);
}
include "../etc/locale/tirtayasa_{$locale}.php";
// Set region and validate
$region = retrieve_from_get($proto_region, false);
if (is_null($region)) {
    if (isset($_COOKIE[$proto_region])) {
        $region = validateRegion($_COOKIE[$proto_region]);
    } else {
        $region = $proto_region_bandung;
    }
} else {
    // region is enforced, save it to cookie.
    $region = validateRegion($region);
    setcookie($proto_region, $region, time() + $cookie_expiry);
示例#7
0
 function getOptionsSupported()
 {
     $host = $_SERVER['HTTP_HOST'];
     $matches = explode('.', $host);
     if (validateLocale($matches[0], 'Dynamic Locale')) {
         array_shift($matches);
         $host = implode('.', $matches);
     }
     $localdesc = '<p>' . sprintf(gettext('If checked links to the alternative languages will be in the form <code><em>language</em>.%1$s</code> where <code><em>language</em></code> is the language code, e.g. <code><em>fr</em></code> for French.'), $host) . '</p>';
     $localdesc .= '<p>' . sprintf(gettext('This requires that you have created the appropriate subdomains pointing to your installation. That is <code>fr.%1$s</code> must point to the same location as <code>%1$s</code>. (Some providers will automatically redirect undefined subdomains to the main domain. If your provider does this, no subdomain creation is needed.)'), $host . WEBPATH) . '</p>';
     $options = array(gettext('Cache control') => array('key' => 'htmlmeta_cache_control', 'type' => OPTION_TYPE_SELECTOR, 'order' => 0, 'selections' => array('no-cache' => "no-cache", 'public' => "public", 'private' => "private", 'no-store' => "no-store"), 'desc' => gettext("If the browser cache should be used.")), gettext('Pragma') => array('key' => 'htmlmeta_pragma', 'type' => OPTION_TYPE_SELECTOR, 'order' => 2, 'selections' => array('no-cache' => "no-cache", 'cache' => "cache"), 'desc' => gettext("If the pages should be allowed to be cached on proxy servers.")), gettext('Robots') => array('key' => 'htmlmeta_robots', 'type' => OPTION_TYPE_SELECTOR, 'order' => 3, 'selections' => array('noindex' => "noindex", 'index' => "index", 'nofollow' => "nofollow", 'noindex,nofollow' => "noindex,nofollow", 'noindex,follow' => "noindex,follow", 'index,nofollow' => "index,nofollow", 'none' => "none"), 'desc' => gettext("If and how robots are allowed to visit the site. Default is “index”. Note that you also should use a robot.txt file.")), gettext('Revisit after') => array('key' => 'htmlmeta_revisit_after', 'type' => OPTION_TYPE_NUMBER, 'order' => 4, 'desc' => gettext("Request the crawler to revisit the page after x days.")), gettext('Expires') => array('key' => 'htmlmeta_expires', 'type' => OPTION_TYPE_NUMBER, 'order' => 5, 'desc' => gettext("When the page should be loaded directly from the server and not from any cache. You can either set a date/time in international date format <em>Sat, 15 Dec 2001 12:00:00 GMT (example)</em> or a number. A number then means seconds, the default value <em>43200</em> means 12 hours.")), gettext('Canonical URL link') => array('key' => 'htmlmeta_canonical-url', 'type' => OPTION_TYPE_CHECKBOX, 'order' => 6, 'desc' => gettext('This adds a link element to the head of each page with a <em>canonical url</em>. If <code>Language links</code> from the <em>dynamic-locale</em> plugin is enabled it also generates alternate links for other languages (<code>&lt;link&nbsp;rel="alternate" hreflang="</code>...<code>" href="</code>...<code>" /&gt;</code>).')), gettext('Site logo') => array('key' => 'htmlmeta_sitelogo', 'type' => OPTION_TYPE_TEXTBOX, 'desc' => gettext("Enter the full url to a specific site logo image. Facebook, Google+ and others will use that as the thumb shown in link previews within posts. For image or album pages the default size album or image thumb is used automatically.")), gettext('Twitter name') => array('key' => 'htmlmeta_twittername', 'type' => OPTION_TYPE_TEXTBOX, 'desc' => gettext("If you enabled Twitter card meta tags, you need to enter your Twitter user name here.")), gettext('Open graph image - width') => array('key' => 'htmlmeta_ogimage_width', 'type' => OPTION_TYPE_TEXTBOX, 'desc' => gettext("Max width of the open graph image used for sharing to social networks if enabled.")), gettext('Open graph image - height') => array('key' => 'htmlmeta_ogimage_height', 'type' => OPTION_TYPE_TEXTBOX, 'desc' => gettext("Max height of the open graph image used for sharing to social networks if enabled.")), gettext('HTML meta tags') => array('key' => 'htmlmeta_tags', 'type' => OPTION_TYPE_CHECKBOX_UL, 'order' => 12, "checkboxes" => array("http-equiv='cache-control'" => "htmlmeta_http-equiv-cache-control", "http-equiv='pragma'" => "htmlmeta_http-equiv-pragma", "http-equiv='content-style-type'" => "htmlmeta_http-equiv-content-style-type", "name='keywords'" => "htmlmeta_name-keywords", "name='description'" => "htmlmeta_name-description", "name='page-topic'" => "htmlmeta_name-page-topic", "name='robots'" => "htmlmeta_name-robots", "name='publisher'" => "htmlmeta_name-publisher", "name='creator'" => "htmlmeta_name-creator", "name='author'" => "htmlmeta_name-author", "name='copyright'" => "htmlmeta_name-copyright", "name='rights'" => "htmlmeta_name-rights", "name='generator' ('ZenPhoto20')" => "htmlmeta_name-generator", "name='revisit-after'" => "htmlmeta_name-revisit-after", "name='expires'" => "htmlmeta_name-expires", "name='date'" => "htmlmeta_name-date", "property='og:title'" => "htmlmeta_og-title", "property='og:image'" => "htmlmeta_og-image", "property='og:description'" => "htmlmeta_og-description", "property='og:url'" => "htmlmeta_og-url", "property='og:type'" => "htmlmeta_og-type", "name='pinterest' content='nopin'" => "htmlmeta_name-pinterest", "twitter:card" => "htmlmeta_twittercard"), "desc" => gettext("Which of the HTML meta tags should be used. For info about these in detail please refer to the net.")), gettext('Keyword threshold') => array('key' => 'htmlmeta_tags_threshold', 'type' => OPTION_TYPE_NUMBER, 'order' => 13, 'limits' => array('min' => 1), 'desc' => gettext('Only keywords with at least this number of uses will be shown.')));
     return $options;
 }
/**
 * Returns a saved (or posted) locale. Posted locales are stored as a cookie.
 *
 * Sets the 'locale' option to the result (non-persistent)
 */
function getUserLocale()
{
    global $_zp_current_admin_obj;
    if (DEBUG_LOCALE) {
        debugLogBackTrace("getUserLocale()");
    }
    if (isset($_REQUEST['locale'])) {
        if (isset($_POST['locale'])) {
            $locale = validateLocale(sanitize($_POST['locale'], 0), 'POST');
        } else {
            $locale = validateLocale(sanitize($_GET['locale'], 0), 'URI string');
        }
        if ($locale) {
            zp_setCookie('dynamic_locale', $locale);
        }
        if (DEBUG_LOCALE) {
            debugLog("dynamic_locale from URL: " . sanitize($_REQUEST['locale'], 0) . "=>{$locale}");
        }
    } else {
        $locale = false;
    }
    if (!$locale && is_object($_zp_current_admin_obj)) {
        $locale = $_zp_current_admin_obj->getLanguage();
        if (DEBUG_LOCALE) {
            debugLog("locale from user: "******"locale from option: " . $localeOption . '; dynamic locale=' . $locale);
        }
        if (empty($localeOption) && empty($locale)) {
            // if one is not set, see if there is a match from 'HTTP_ACCEPT_LANGUAGE'
            $languageSupport = generateLanguageList();
            $userLang = parseHttpAcceptLanguage();
            foreach ($userLang as $lang) {
                $l = strtoupper($lang['fullcode']);
                $locale = validateLocale($l, 'HTTP Accept Language');
                if ($locale) {
                    break;
                }
            }
        } else {
            if (empty($locale)) {
                $locale = $localeOption;
            }
        }
    }
    if (empty($locale)) {
        // return "default" language, English if allowed, otherwise whatever is the "first" allowed language
        $languageSupport = generateLanguageList();
        if (in_array('en_US', $languageSupport)) {
            $locale = 'en_US';
        } else {
            $locale = array_shift($languageSupport);
        }
    } else {
        setOption('locale', $locale, false);
    }
    if (DEBUG_LOCALE) {
        debugLog("getUserLocale Returning locale: " . $locale);
    }
    return $locale;
}