Ejemplo n.º 1
0
function qtranxf_http_negotiate_language()
{
    global $q_config;
    if (function_exists('http_negotiate_language')) {
        $default_language = $q_config['default_language'];
        $supported = array();
        $supported[] = qtranxf_html_locale($q_config['locale'][$default_language]);
        //needs to be the first
        if (!empty($q_config['locale_html'][$default_language])) {
            $supported[] = $q_config['locale_html'][$default_language];
        }
        foreach ($q_config['enabled_languages'] as $lang) {
            if ($lang == $default_language) {
                continue;
            }
            $supported[] = qtranxf_html_locale($q_config['locale'][$lang]);
            if (!empty($q_config['locale_html'][$lang])) {
                $supported[] = $q_config['locale_html'][$lang];
            }
        }
        $fallback = array();
        $locale_negotiated = http_negotiate_language($supported, $fallback);
        if ($fallback == NULL) {
            $locale_negotiated = 'en';
        }
        return qtranxf_match_language_locale($locale_negotiated);
    } else {
        return qtranxf_get_browser_language();
    }
}
Ejemplo n.º 2
0
<?php

/*USE http_negotiate_language TO GET THE USER'S LOCALE AND USE IT FOR THE APP*/
$langs = array('en', 'en-us', 'en-gb', 'bs', 'bs_BA');
if (function_exists('http_negotiate_language')) {
    $locale = http_negotiate_language($langs, $result);
} else {
    $locale = http\Env::negotiateLanguage($langs, $result);
    //returns bs_BA so we trim
    $locale = substr($locale, 0, 2);
}
$paginationLocaleFile = 'paginationLocales' . DIRECTORY_SEPARATOR . $locale . '.txt';
Yii::app()->setLanguage($locale);
if (file_exists($paginationLocaleFile)) {
    Yii::app()->session->add('locale', $locale);
} else {
    Yii::app()->session->add('locale', 'en');
}
$this->pageTitle = Yii::app()->name . Yii::t("translation", " - Login");
//$this->breadcrumbs = array(
//'Login',
//);
//remove the trailing asteriks
CHtml::$afterRequiredLabel = '';
?>
<div id="bd">
	<div class="form">
		<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'login-form', 'enableClientValidation' => false, 'clientOptions' => array('validateOnSubmit' => true)));
?>
		<!--<div class="login-error"><?php 
Ejemplo n.º 3
0
    } else {
        if (!is_writeable($log_dir)) {
            throw new \RuntimeException('Log directory (' . $log_dir . ') is not writeable!');
        }
    }
    $log_file = $log_dir . 'viewer.log';
    $logger = \Analog\Handler\File::init($log_file);
}
Analog::handler(\Analog\Handler\LevelBuffer::init($logger, $log_lvl));
$conf = new Conf();
/** I18n stuff */
$lang = null;
$langs = array('en-US', 'fr-FR');
/** Try to detect user language */
if (function_exists('http_negotiate_language')) {
    $nego = http_negotiate_language($langs);
    switch (strtolower($nego)) {
        case 'en-us':
            $lang = 'en_US';
            break;
        case 'fr-fr':
            $lang = 'fr_FR.utf8';
            break;
    }
} else {
    if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
        $langs = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
        if (substr($langs, 0, 2) == 'fr') {
            $lang = 'fr_FR.utf8';
        }
    }
Ejemplo n.º 4
0
 /**
  * Ask the user's browser which language they would like us to use
  */
 public function changeLanguageBasedOnBrowserHint()
 {
     if (function_exists('http_negotiate_language')) {
         $this->changeLanguage(http_negotiate_language(array_keys($this->languages)));
     }
 }
Ejemplo n.º 5
0
function qtranxf_http_negotiate_language()
{
    global $q_config;
    if (function_exists('http_negotiate_language')) {
        $supported = array();
        $supported[] = str_replace('_', '-', $q_config['locale'][$q_config['default_language']]);
        //needs to be the first
        foreach ($q_config['enabled_languages'] as $lang) {
            if ($lang == $q_config['default_language']) {
                continue;
            }
            $supported[] = str_replace('_', '-', $q_config['locale'][$lang]);
        }
        $locale_negotiated = http_negotiate_language($supported);
        //since 3.2-b3 added search, since locale may be different from two-letter code and not even started with language code.
        foreach ($q_config['enabled_languages'] as $lang) {
            $locale = str_replace('_', '-', $q_config['locale'][$lang]);
            if ($locale == $locale_negotiated) {
                return $lang;
            }
        }
    } else {
        return qtranxf_get_browser_language();
    }
    return null;
}
function Render3UUShariff($atts, $content = null)
{
    // get options
    $shariff3UU = $GLOBALS["shariff3UU"];
    // avoid errors if no attributes are given - instead use the old set of services to make it backward compatible
    if (empty($shariff3UU["services"])) {
        $shariff3UU["services"] = "twitter|facebook|googleplus|info";
    }
    // use the backend option for every option that is not set in the shorttag
    $backend_options = $shariff3UU;
    if (isset($shariff3UU["vertical"])) {
        if ($shariff3UU["vertical"] == '1') {
            $backend_options["orientation"] = 'vertical';
        }
    }
    if (isset($shariff3UU["backend"])) {
        if ($shariff3UU["backend"] == '1') {
            $backend_options["backend"] = 'on';
        }
    }
    if (isset($shariff3UU["buttonsize"])) {
        if ($shariff3UU["buttonsize"] == '1') {
            $backend_options["buttonsize"] = 'small';
        }
    }
    if (empty($atts)) {
        $atts = $backend_options;
    } else {
        $atts = array_merge($backend_options, $atts);
    }
    // remove empty elements (no need to write data-something="" to html)
    $atts = array_filter($atts);
    // make sure that default WP jquery is loaded
    #rtzrtz_ Hm, die sollten wir dann potenziell vielleicht auch vom externen Server holen. Nochens gruebeln, was es fuer Seiteneffekte hat!
    #jp: Da wir grundsätzlich die WP-Variante von jQuery verwenden, sehe ich keinen Sinn darin, die bereits vorhande Verison erneut von extern zu laden, außerdem ist die Wahrscheinlichkeit hoch, dass es bereits von einem anderen Plugin geladen wurde. Im worst case laden wir jQuery nachher doppelt.
    wp_enqueue_script('jquery');
    // the JS must be loaded at footer - make sure that wp_footer() is present in your theme!
    if (isset($GLOBALS["shariff3UU_statistic"]["external_host"])) {
        wp_enqueue_script('shariffjs', $GLOBALS["shariff3UU_statistic"]["external_host"] . 'shariff.js', '', '', true);
    } else {
        wp_enqueue_script('shariffjs', plugins_url('/shariff.js', __FILE__), '', '', true);
    }
    // clean up headline in case it was used in a shorttag
    if (array_key_exists('headline', $atts)) {
        $atts['headline'] = wp_kses($atts['headline'], $GLOBALS["allowed_tags"]);
    }
    // prevent an error notice while debug mode is on, because of "undefined variable" when using .=
    $output = '';
    // if we have a style attribute and / or a headline, add it
    if (array_key_exists('style', $atts) || array_key_exists('headline', $atts)) {
        // container
        $output .= '<div class="ShariffSC"';
        // style attributes
        if (array_key_exists('style', $atts)) {
            $output .= ' style="' . esc_html($atts['style']) . '">';
        } else {
            $output .= '>';
        }
        // headline
        if (array_key_exists('headline', $atts)) {
            $output .= '<div class="ShariffHeadline">' . $atts['headline'] . '</div>';
        }
    }
    // start output of actual shorttag
    $output .= '<div class="shariff"';
    // set the url attribute. Usefull e.g. in widgets that should point main page instead of a single post
    if (array_key_exists('url', $atts)) {
        $output .= ' data-url="' . esc_url($atts['url']) . '"';
    } else {
        $output .= ' data-url="' . esc_url(get_permalink()) . '"';
    }
    // same for the title attribute
    if (array_key_exists('title', $atts)) {
        $output .= ' data-title="' . esc_html($atts['title']) . '"';
    } else {
        $output .= ' data-title="' . strip_tags(get_the_title()) . '"';
    }
    // set the options
    if (array_key_exists('info_url', $atts)) {
        $output .= ' data-info-url="' . esc_html($atts['info_url']) . '"';
    }
    if (array_key_exists('orientation', $atts)) {
        $output .= ' data-orientation="' . esc_html($atts['orientation']) . '"';
    }
    if (array_key_exists('theme', $atts)) {
        $output .= ' data-theme="' . esc_html($atts['theme']) . '"';
    }
    // if no language is set, try http_negotiate_language otherwise fallback language in JS is used
    if (array_key_exists('lang', $atts)) {
        $output .= ' data-lang="' . esc_html($atts['lang']) . '"';
    } elseif (function_exists('http_negotiate_language')) {
        $available_lang = array('en', 'de', 'fr', 'es', 'zh', 'hr', 'da', 'nl', 'fi', 'it', 'ja', 'ko', 'no', 'pl', 'pt', 'ro', 'ru', 'sk', 'sl', 'sr', 'sv', 'tr');
        $lang = http_negotiate_language($available_lang);
        $output .= ' data-lang="' . esc_html($lang) . '"';
    }
    if (array_key_exists('twitter_via', $atts)) {
        $output .= ' data-twitter-via="' . esc_html($atts['twitter_via']) . '"';
    }
    if (array_key_exists('flattruser', $atts)) {
        $output .= ' data-flattruser="******"';
    }
    if (array_key_exists('patreonid', $atts)) {
        $output .= ' data-patreonid="' . esc_html($atts['patreonid']) . '"';
    }
    if (array_key_exists('paypalbuttonid', $atts)) {
        $output .= ' data-paypalbuttonid="' . esc_html($atts['paypalbuttonid']) . '"';
    }
    if (array_key_exists('paypalmeid', $atts)) {
        $output .= ' data-paypalmeid="' . esc_html($atts['paypalmeid']) . '"';
    }
    if (array_key_exists('bitcoinaddress', $atts)) {
        $output .= ' data-bitcoinaddress="' . esc_html($atts['bitcoinaddress']) . '"';
    }
    if (array_key_exists('bitcoinaddress', $atts)) {
        $output .= ' data-bitcoinurl="' . esc_url(plugins_url('/', __FILE__)) . '"';
    }
    if (array_key_exists('buttonsize', $atts)) {
        $output .= ' data-buttonsize="' . esc_html($atts['buttonsize']) . '"';
    }
    if (array_key_exists('timestamp', $atts)) {
        $output .= ' data-timestamp="' . esc_html($atts['timestamp']) . '"';
    }
    // if services are set only use these
    if (array_key_exists('services', $atts)) {
        // build an array
        $s = explode('|', $atts["services"]);
        $output .= ' data-services=\'[';
        // prevent error while debug mode is on
        $strServices = '';
        $flattr_error = '';
        $paypal_error = '';
        $paypalme_error = '';
        $bitcoin_error = '';
        $patreon_error = '';
        // walk
        while (list($key, $val) = each($s)) {
            // services without usernames, etc.
            if ($val != 'flattr' && $val != 'paypal' && $val != 'bitcoin' && $val != 'patreon' && $val != 'paypalme') {
                $strServices .= '"' . $val . '", ';
            } elseif ($val == 'flattr' && array_key_exists('flattruser', $atts)) {
                $strServices .= '"' . $val . '", ';
            } elseif ($val == 'flattr') {
                $flattr_error = '1';
            } elseif ($val == 'paypal' && array_key_exists('paypalbuttonid', $atts)) {
                $strServices .= '"' . $val . '", ';
            } elseif ($val == 'paypal') {
                $paypal_error = '1';
            } elseif ($val == 'paypalme' && array_key_exists('paypalmeid', $atts)) {
                $strServices .= '"' . $val . '", ';
            } elseif ($val == 'paypalme') {
                $paypalme_error = '1';
            } elseif ($val == 'bitcoin' && array_key_exists('bitcoinaddress', $atts)) {
                $strServices .= '"' . $val . '", ';
            } elseif ($val == 'bitcoin') {
                $bitcoin_error = '1';
            } elseif ($val == 'patreon' && array_key_exists('patreonid', $atts)) {
                $strServices .= '"' . $val . '", ';
            } elseif ($val == 'patreon') {
                $patreon_error = '1';
            }
        }
        // remove the separator and add it to output
        $output .= substr($strServices, 0, -2);
        $output .= ']\'';
    }
    // get an image for pinterest (attribut -> featured image -> first image -> default image -> shariff hint)
    if (array_key_exists('services', $atts)) {
        if (strstr($atts["services"], 'pinterest')) {
            if (array_key_exists('media', $atts)) {
                $output .= " data-media='" . esc_html($atts['media']) . "'";
            } else {
                $feat_image = wp_get_attachment_url(get_post_thumbnail_id());
                if (!empty($feat_image)) {
                    $output .= " data-media='" . esc_html($feat_image) . "'";
                } else {
                    $first_image = catch_image();
                    if (!empty($first_image)) {
                        $output .= " data-media='" . esc_html($first_image) . "'";
                    } else {
                        if (isset($shariff3UU["default_pinterest"])) {
                            $output .= " data-media='" . $shariff3UU["default_pinterest"] . "'";
                        } else {
                            $output .= " data-media='" . plugins_url('/pictos/defaultHint.png', __FILE__) . "'";
                        }
                    }
                }
            }
        }
    }
    // enable share counts
    if (array_key_exists('backend', $atts) && $atts['backend'] == "on") {
        // set backend_url to external server, if configured, otherwiese use local backend
        if (isset($GLOBALS["shariff3UU_statistic"]["external_host"])) {
            $data_backen_url = esc_url($GLOBALS["shariff3UU_statistic"]["external_host"] . 'backend/index.php');
        } else {
            $data_backen_url = esc_url(plugins_url('/backend/index.php', __FILE__));
        }
        // add to output
        $output .= " data-backend-url='{$data_backen_url}'";
    }
    // close the container
    $output .= '></div>';
    // display warning to admins if flattr is set, but no flattr username is provided
    if ($flattr_error == '1' && current_user_can('manage_options')) {
        $output .= '<div class="flattr_warning">' . __('Username for Flattr is missing!', 'shariff3UU') . '</div>';
    }
    // display warning to admins if patreon is set, but no patreon username is provided
    if ($patreon_error == '1' && current_user_can('manage_options')) {
        $output .= '<div class="flattr_warning">' . __('Username for patreon is missing!', 'shariff3UU') . '</div>';
    }
    // display warning to admins if paypal is set, but no paypal button id is provided
    if ($paypal_error == '1' && current_user_can('manage_options')) {
        $output .= '<div class="flattr_warning">' . __('Button ID for PayPal is missing!', 'shariff3UU') . '</div>';
    }
    // display warning to admins if paypalme is set, but no paypalme id is provided
    if ($paypalme_error == '1' && current_user_can('manage_options')) {
        $output .= '<div class="flattr_warning">' . __('PayPal.Me ID is missing!', 'shariff3UU') . '</div>';
    }
    // display warning to admins if bitcoin is set, but no bitcoin address is provided
    if ($bitcoin_error == '1' && current_user_can('manage_options')) {
        $output .= '<div class="flattr_warning">' . __('Address for Bitcoin is missing!', 'shariff3UU') . '</div>';
    }
    // if we had a style attribute or a headline, close that too
    if (array_key_exists('style', $atts) || array_key_exists('headline', $atts)) {
        $output .= '</div>';
    }
    return $output;
}
Ejemplo n.º 7
0
/**
 * Test Http functions.
 */
function test_functions()
{
    http_cache_last_modified();
    http_chunked_decode();
    http_deflate();
    http_inflate();
    http_build_cookie();
    http_date();
    http_get_request_body_stream();
    http_get_request_body();
    http_get_request_headers();
    http_match_etag();
    http_match_modified();
    http_match_request_header();
    http_support();
    http_negotiate_charset();
    http_negotiate_content_type();
    http_negotiate_language();
    ob_deflatehandler();
    ob_etaghandler();
    ob_inflatehandler();
    http_parse_cookie();
    http_parse_headers();
    http_parse_message();
    http_parse_params();
    http_persistent_handles_clean();
    http_persistent_handles_count();
    http_persistent_handles_ident();
    http_get();
    http_head();
    http_post_data();
    http_post_fields();
    http_put_data();
    http_put_file();
    http_put_stream();
    http_request_body_encode();
    http_request_method_exists();
    http_request_method_name();
    http_request_method_register();
    http_request_method_unregister();
    http_request();
    http_redirect();
    http_send_content_disposition();
    http_send_content_type();
    http_send_data();
    http_send_file();
    http_send_last_modified();
    http_send_status();
    http_send_stream();
    http_throttle();
    http_build_str();
    http_build_url();
}