本文整理汇总了PHP中getUserLocale函数的典型用法代码示例。如果您正苦于以下问题:PHP getUserLocale函数的具体用法?PHP getUserLocale怎么用?PHP getUserLocale使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getUserLocale函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: new_image
static function new_image($image)
{
global $_zp_exifvars;
$entry_locale = getUserLocale();
$languages = generateLanguageList();
$languageTags = $element = array();
$candidates = self::getTaggingItems();
foreach ($candidates as $key) {
if ($meta = $image->get($key)) {
setupCurrentLocale('en_US');
$en_us = $element[] = exifTranslate($meta);
foreach ($languages as $language) {
setupCurrentLocale($language);
$xlated = exifTranslate($meta);
if ($xlated != $en_us) {
// the string has a translation in this language
$element[] = $xlated;
$languageTags[$language] = $xlated;
}
}
}
}
setupCurrentLocale($entry_locale);
$element = array_unique(array_merge($image->getTags(), $element));
$image->setTags($element);
$image->save();
foreach ($languageTags as $language => $tag) {
$sql = 'UPDATE ' . prefix('tags') . ' SET `language`=' . db_quote($language) . ' WHERE `name`=' . db_quote($tag) . ' AND `language`=NULL OR `language` LIKE ""';
query($sql, false);
}
return $image;
}
示例2: __construct
function __construct()
{
if (OFFSET_PATH == 2) {
$seo_locale = extensionEnabled('seo_locale') && getOption('dynamic_locale_subdomain') != 2;
setOptionDefault('dynamic_locale_visual', 0);
setOptionDefault('dynamic_locale_subdomain', (int) $seo_locale);
setOptionDefault('dynamic_locale_base', getUserLocale());
}
}
示例3: getAllTranslations
/**
* returns a serialized "multilingual array" of translations
* Used for setting default options with multi-lingual strings.
* @param string $text to be translated
*/
function getAllTranslations($text)
{
$entry_locale = getUserLocale();
$result = array('en_US' => $text);
$languages = generateLanguageList();
$key = array_search('en_US', $languages);
unset($languages[$key]);
foreach ($languages as $language) {
setupCurrentLocale($language);
$xlated = gettext($text);
if ($xlated != $text) {
// the string has a translation in this language
$result[$language] = $xlated;
}
}
setupCurrentLocale($entry_locale);
return serialize($result);
}
示例4: Logger
/**
* Does the log handling
*
* @param int $success
* @param string $user
* @param string $name
* @param string $ip
* @param string $type
* @param string $authority kind of login
* @param string $addl more info
*/
private static function Logger($success, $user, $name, $action, $authority, $addl = NULL)
{
global $_zp_authority, $_zp_mutex;
$pattern = '~^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$~';
$forwardedIP = NULL;
$ip = sanitize($_SERVER['REMOTE_ADDR']);
if (!preg_match($pattern, $ip)) {
$ip = NULL;
}
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$forwardedIP = sanitize($_SERVER['HTTP_X_FORWARDED_FOR']);
if (preg_match($pattern, $forwardedIP)) {
$ip .= ' {' . $forwardedIP . '}';
}
}
$admin = $_zp_authority->getMasterUser();
$locale = $admin->getLanguage();
if (empty($locale)) {
$locale = 'en_US';
}
$cur_locale = getUserLocale();
setupCurrentLocale($locale);
// the log will be in the language of the master user.
switch ($action) {
case 'clear_log':
$type = gettext('Log reset');
break;
case 'delete_log':
$type = gettext('Log deleted');
break;
case 'download_log':
$type = gettext('Log downloaded');
break;
case 'setup_install':
$type = gettext('Install');
$addl = gettext('version') . ' ' . ZENPHOTO_VERSION . '[' . ZENPHOTO_RELEASE . "]";
if (!zpFunctions::hasPrimaryScripts()) {
$addl .= ' ' . gettext('clone');
}
break;
case 'setup_proptect':
$type = gettext('Protect setup scripts');
break;
case 'user_new':
$type = gettext('Request add user');
break;
case 'user_update':
$type = gettext('Request update user');
break;
case 'user_delete':
$type = gettext('Request delete user');
break;
case 'XSRF_blocked':
$type = gettext('Cross Site Reference');
break;
case 'blocked_album':
$type = gettext('Album access');
break;
case 'blocked_access':
$type = gettext('Admin access');
break;
case 'Front-end':
$type = gettext('Guest login');
break;
case 'Back-end':
$type = gettext('Admin login');
break;
case 'auth_cookie':
$type = gettext('Authorization cookie check');
break;
default:
$type = $action;
break;
}
$file = SERVERPATH . '/' . DATA_FOLDER . '/security.log';
$max = getOption('security_log_size');
$_zp_mutex->lock();
if ($max && @filesize($file) > $max) {
switchLog('security');
}
$preexists = file_exists($file) && filesize($file) > 0;
$f = fopen($file, 'a');
if ($f) {
if (!$preexists) {
// add a header
fwrite($f, gettext('date' . "\t" . 'requestor’s IP' . "\t" . 'type' . "\t" . 'user ID' . "\t" . 'user name' . "\t" . 'outcome' . "\t" . 'authority' . "\tadditional information\n"));
}
$message = date('Y-m-d H:i:s') . "\t";
$message .= $ip . "\t";
//.........这里部分代码省略.........
示例5: array_slice
$separator = '.';
}
$x = array_slice(explode($separator, $full_ip), 0, $__config['accessThreshold_SENSITIVITY']);
$ip = implode($separator, $x);
unset($x);
if (isset($recentIP[$ip]['lastAccessed']) && $__time - $recentIP[$ip]['lastAccessed'] > $__config['accessThreshold_IP_ACCESS_WINDOW']) {
$recentIP[$ip] = array('accessed' => array(), 'locales' => array(), 'blocked' => 0, 'interval' => 0);
}
$recentIP[$ip]['lastAccessed'] = $__time;
if (@$recentIP[$ip]['blocked']) {
file_put_contents(SERVERPATH . '/' . DATA_FOLDER . '/recentIP', serialize($recentIP));
$mu->unlock();
exitZP();
} else {
$recentIP[$ip]['accessed'][] = array('time' => $__time, 'ip' => $full_ip);
$__locale = getUserLocale();
if (isset($recentIP[$ip]['locales'][$__locale])) {
$recentIP[$ip]['locales'][$__locale]['ip'][$full_ip] = $__time;
} else {
$recentIP[$ip]['locales'][$__locale] = array('time' => $__time, 'ip' => array($full_ip => $__time));
}
$__previous = $__interval = $__count = 0;
array_walk($recentIP[$ip]['locales'], 'accessThreshold::walk', $__time);
foreach ($recentIP[$ip]['locales'] as $key => $data) {
if (is_null($data)) {
unset($recentIP[$ip]['locales'][$key]);
}
}
if ($__count > $__config['accessThreshold_LocaleCount']) {
$recentIP[$ip]['blocked'] = 1;
}
示例6: printLoginForm
/**
* Print the login form for ZP. This will take into account whether mod_rewrite is enabled or not.
*
* @param string $redirect URL to return to after login
* @param bool $logo set to true to display the ADMIN zenphoto logo.
* @param bool $showUserField set to true to display the user input
* @param bool $showCaptcha set to false to not display the forgot password captcha.
* @param string $hint optional hint for the password
*
*/
function printLoginForm($redirect = null, $logo = true, $showUserField = true, $showCaptcha = true, $hint = '')
{
global $_zp_login_error, $_zp_captcha, $_zp_gallery;
if (is_null($redirect)) {
$redirect = getRequestURI();
}
if (is_null($showUserField)) {
$showUserField = $_zp_gallery->getUserLogonField();
}
$cycle = sanitize_numeric(@$_GET['cycle']) + 1;
if (isset($_POST['user'])) {
$requestor = sanitize($_POST['user'], 0);
} else {
$requestor = '';
}
if (empty($requestor)) {
if (isset($_GET['ref'])) {
$requestor = sanitize($_GET['ref']);
}
}
$alt_handlers = zp_apply_filter('alt_login_handler', array());
$star = false;
$mails = array();
$info = array('challenge' => '', 'response' => '');
if (!empty($requestor)) {
if ($admin = $this->getAnAdmin(array('`user`=' => $requestor, '`valid`=' => 1))) {
$info = $admin->getChallengePhraseInfo();
} else {
$info = array('challenge' => '');
}
if (empty($info['challenge']) || $cycle > 2 && $cycle % 5 != 1) {
$locale = getUserLocale();
$questions = array();
foreach (getSerializedArray(getOption('challenge_foils')) as $question) {
$questions[] = get_language_string($question);
}
$rslt = query('SELECT `challenge_phrase`,`language` FROM ' . prefix('administrators') . ' WHERE `challenge_phrase` IS NOT NULL');
while ($row = db_fetch_assoc($rslt)) {
if (is_null($row['language']) || $row['language'] == $locale) {
$q = getSerializedArray($row['challenge_phrase']);
$questions[] = $q['challenge'];
}
}
db_free_result($rslt);
$questions = array_unique($questions);
shuffle($questions);
$info = array('challenge' => $questions[$cycle % count($questions)], 'response' => 0x0);
} else {
if ($admin->getEmail()) {
$star = $showCaptcha;
}
}
}
if (!$star) {
$admins = $this->getAdministrators();
while (count($admins) > 0) {
$user = array_shift($admins);
if ($user['email']) {
$star = $showCaptcha;
}
}
}
$whichForm = sanitize(@$_REQUEST['logon_step']);
?>
<div id="loginform">
<?php
if ($logo) {
?>
<p>
<img src="<?php
echo WEBPATH . '/' . ZENFOLDER;
?>
/images/zen-logo.png" title="ZenPhoto" alt="ZenPhoto" />
</p>
<?php
}
switch ($_zp_login_error) {
case 1:
?>
<div class="errorbox" id="message"><h2><?php
echo gettext("There was an error logging in.");
?>
</h2>
<?php
if ($showUserField) {
echo gettext("Check your username and password and try again.");
} else {
echo gettext("Check password and try again.");
}
?>
//.........这里部分代码省略.........
示例7: print_language_string_list
/**
* Generates an editable list of language strings
*
* @param string $dbstring either a serialized languag string array or a single string
* @param string $name the prefix for the label, id, and name tags
* @param bool $textbox set to true for a textbox rather than a text field
* @param string $locale optional locale of the translation desired
* @param string $edit optional class
*/
function print_language_string_list($dbstring, $name, $textbox = false, $locale = NULL, $edit = '')
{
global $_zp_languages, $_zp_active_languages, $_zp_current_locale;
if (!empty($edit)) {
$edit = ' class="' . $edit . '"';
}
if (is_null($locale)) {
if (is_null($_zp_current_locale)) {
$_zp_current_locale = getUserLocale();
if (empty($_zp_current_locale)) {
$_zp_current_locale = 'en_US';
}
}
$locale = $_zp_current_locale;
}
if (preg_match('/^a:[0-9]+:{/', $dbstring)) {
$strings = unserialize($dbstring);
} else {
$strings = array($locale => $dbstring);
}
if (getOption('multi_lingual')) {
if (is_null($_zp_active_languages)) {
$_zp_active_languages = generateLanguageList();
}
$emptylang = array_flip($_zp_active_languages);
unset($emptylang['']);
natsort($emptylang);
if ($textbox) {
$class = 'box';
} else {
$class = '';
}
echo "<ul class=\"language_string_list" . $class . "\">\n";
$empty = true;
foreach ($emptylang as $key => $lang) {
if (isset($strings[$key])) {
$string = $strings[$key];
if (!empty($string)) {
unset($emptylang[$key]);
$empty = false;
echo '<li><label for="' . $name . '_' . $key . '">';
echo $lang;
if ($textbox) {
echo "\n" . '<textarea name="' . $name . '_' . $key . '"' . $edit . ' cols="' . TEXTAREA_COLUMNS . '" style="width: 310px" rows="6">' . $string . '</textarea>';
} else {
echo '<br /><input id="' . $name . '_' . $key . '" name="' . $name . '_' . $key . '" type="text" value="' . $string . '" style="width: 310px" size="' . TEXT_INPUT_SIZE . '" />';
}
echo "</label></li>\n";
}
}
}
if ($empty) {
$element = $emptylang[$locale];
unset($emptylang[$locale]);
$emptylang = array_merge(array($locale => $element), $emptylang);
}
foreach ($emptylang as $key => $lang) {
echo '<li><label for="' . $name . '_' . $key . '">';
echo $lang;
if ($textbox) {
echo "\n" . '<textarea name="' . $name . '_' . $key . '"' . $edit . ' cols="' . TEXTAREA_COLUMNS . '" style="width: 310px" rows="6"></textarea>';
} else {
echo '<br /><input id="' . $name . '_' . $key . '" name="' . $name . '_' . $key . '" type="text" value="" style="width: 310px" size="' . TEXT_INPUT_SIZE . '" />';
}
echo "</label></li>\n";
}
echo "</ul>\n";
} else {
if (empty($locale)) {
$locale = 'en_US';
}
if (isset($strings[$locale])) {
$dbstring = $strings[$locale];
} else {
$dbstring = array_shift($strings);
}
if ($textbox) {
echo '<textarea name="' . $name . '_' . $locale . '"' . $edit . ' cols="' . TEXTAREA_COLUMNS . '" rows="6">' . $dbstring . '</textarea>';
} else {
echo '<input id="' . $name . '_' . $locale . '" name="' . $name . '_' . $locale . '" type="text" value="' . $dbstring . '" size="' . TEXT_INPUT_SIZE . '" />';
}
}
}
示例8: getHTMLMetaData
/**
* Prints html meta data to be used in the <head> section of a page
*
*/
static function getHTMLMetaData()
{
global $_zp_gallery, $_zp_galley_page, $_zp_current_album, $_zp_current_image, $_zp_current_zenpage_news, $_zp_current_zenpage_page, $_zp_gallery_page, $_zp_current_category, $_zp_authority, $_zp_conf_vars, $_myFavorites, $htmlmetatags_need_cache, $_zp_page;
zp_register_filter('image_processor_uri', 'htmlmetatags::ipURI');
$host = sanitize("http://" . $_SERVER['HTTP_HOST']);
$url = $host . getRequestURI();
// Convert locale shorttag to allowed html meta format
$locale = str_replace("_", "-", getUserLocale());
$canonicalurl = '';
// generate page title, get date
$pagetitle = "";
// for gallery index setup below switch
$date = strftime(DATE_FORMAT);
// if we don't have a item date use current date
$desc = getBareGalleryDesc();
$thumb = '';
if (getOption('htmlmeta_sitelogo')) {
$thumb = getOption('htmlmeta_sitelogo');
}
if (getOption('htmlmeta_og-image') || getOption('htmlmeta_twittercard')) {
$ogimage_width = getOption('htmlmeta_ogimage_width');
$ogimage_height = getOption('htmlmeta_ogimage_height');
if (empty($ogimage_width)) {
$ogimage_width = 1280;
}
if (empty($ogimage_height)) {
$ogimage_height = 900;
}
}
$type = 'article';
switch ($_zp_gallery_page) {
case 'index.php':
$desc = getBareGalleryDesc();
//$canonicalurl = $host . getGalleryIndexURL();
$canonicalurl = $host . getPageNumURL($_zp_page);
$type = 'website';
break;
case 'album.php':
$pagetitle = getBareAlbumTitle() . " - ";
$date = getAlbumDate();
$desc = getBareAlbumDesc();
$canonicalurl = $host . getPageNumURL($_zp_page);
if (getOption('htmlmeta_og-image') || getOption('htmlmeta_twittercard')) {
$thumbimg = $_zp_current_album->getAlbumThumbImage();
getMaxSpaceContainer($ogimage_width, $ogimage_height, $thumbimg, false);
$thumb = $host . html_encode(pathurlencode($thumbimg->getCustomImage(NULL, $ogimage_width, $ogimage_height, NULL, NULL, NULL, NULL, false, NULL)));
}
break;
case 'image.php':
$pagetitle = getBareImageTitle() . " (" . getBareAlbumTitle() . ") - ";
$date = getImageDate();
$desc = getBareImageDesc();
$canonicalurl = $host . getImageURL();
if (getOption('htmlmeta_og-image') || getOption('htmlmeta_twittercard')) {
$thumb = $host . html_encode(pathurlencode(getCustomSizedImageMaxSpace($ogimage_width, $ogimage_height)));
}
break;
case 'news.php':
if (function_exists("is_NewsArticle")) {
if (is_NewsArticle()) {
$pagetitle = getBareNewsTitle() . " - ";
$date = getNewsDate();
$desc = trim(getBare(getNewsContent()));
$canonicalurl = $host . $_zp_current_zenpage_news->getLink();
} else {
if (is_NewsCategory()) {
$pagetitle = $_zp_current_category->getTitlelink() . " - ";
$date = strftime(DATE_FORMAT);
$desc = trim(getBare($_zp_current_category->getDesc()));
$canonicalurl = $host . $_zp_current_category->getLink();
$type = 'category';
} else {
$pagetitle = gettext('News') . " - ";
$desc = '';
$canonicalurl = $host . getNewsIndexURL();
$type = 'website';
}
}
if ($_zp_page != 1) {
$canonicalurl .= '/' . $_zp_page;
}
}
break;
case 'pages.php':
$pagetitle = getBarePageTitle() . " - ";
$date = getPageDate();
$desc = trim(getBare(getPageContent()));
$canonicalurl = $host . $_zp_current_zenpage_page->getLink();
break;
default:
// for all other possible static custom pages
$custompage = stripSuffix($_zp_gallery_page);
$standard = array('contact' => gettext('Contact'), 'register' => gettext('Register'), 'search' => gettext('Search'), 'archive' => gettext('Archive view'), 'password' => gettext('Password required'));
if (is_object($_myFavorites)) {
$standard['favorites'] = gettext('My favorites');
}
//.........这里部分代码省略.........
示例9: printStandardMeta
/**
* Central place for meta header handling
*/
function printStandardMeta()
{
$lang = substr(getUserLocale(), 0, 2);
echo '<meta http-equiv="content-type" content="text/html; charset=' . LOCAL_CHARSET . '"';
if ($lang) {
echo ' lang="' . $lang . '"';
}
echo ">\n";
}
示例10: post_processor
static function post_processor()
{
global $admin_e, $admin_n, $user, $_zp_authority, $_zp_captcha, $_zp_gallery, $_notify, $_link, $_message;
//Handle registration
if (isset($_POST['username']) && !empty($_POST['username'])) {
$_notify = 'honeypot';
// honey pot check
}
if (getOption('register_user_captcha')) {
if (isset($_POST['code'])) {
$code = sanitize($_POST['code'], 3);
$code_ok = sanitize($_POST['code_h'], 3);
} else {
$code = '';
$code_ok = '';
}
if (!$_zp_captcha->checkCaptcha($code, $code_ok)) {
$_notify = 'invalidcaptcha';
}
}
$admin_n = trim(sanitize($_POST['admin_name']));
if (empty($admin_n)) {
$_notify = 'incomplete';
}
if (isset($_POST['admin_email'])) {
$admin_e = trim(sanitize($_POST['admin_email']));
} else {
$admin_e = trim(sanitize($_POST['user'], 0));
}
if (!is_valid_email_zp($admin_e)) {
$_notify = 'invalidemail';
}
$pass = trim(sanitize($_POST['pass'], 0));
$user = trim(sanitize($_POST['user'], 0));
if (empty($pass)) {
$_notify = 'empty';
} else {
if (!empty($user) && !empty($admin_n) && !empty($admin_e)) {
if (isset($_POST['disclose_password']) || $pass == trim(sanitize($_POST['pass_r']))) {
$currentadmin = $_zp_authority->getAnAdmin(array('`user`=' => $user, '`valid`>' => 0));
if (is_object($currentadmin)) {
$_notify = 'exists';
} else {
if ($_zp_authority->getAnAdmin(array('`email`=' => $admin_e, '`valid`=' => '1'))) {
$_notify = 'dup_email';
}
}
if (empty($_notify)) {
$userobj = $_zp_authority->newAdministrator('');
$userobj->transient = false;
$userobj->setUser($user);
$userobj->setPass($pass);
$userobj->setName($admin_n);
$userobj->setEmail($admin_e);
$userobj->setRights(0);
$userobj->setObjects(NULL);
$userobj->setGroup('');
$userobj->setCustomData('');
$userobj->setLanguage(getUserLocale());
if (extensionEnabled('userAddressFields')) {
$addresses = getOption('register_user_address_info');
$userinfo = register_user::getUserInfo(0);
$_comment_form_save_post = serialize($userinfo);
if ($addresses == 'required') {
if (!isset($userinfo['street']) || empty($userinfo['street'])) {
$userobj->transient = true;
$userobj->msg .= ' ' . gettext('You must supply the street field.');
}
if (!isset($userinfo['city']) || empty($userinfo['city'])) {
$userobj->transient = true;
$userobj->msg .= ' ' . gettext('You must supply the city field.');
}
if (!isset($userinfo['state']) || empty($userinfo['state'])) {
$userobj->transient = true;
$userobj->msg .= ' ' . gettext('You must supply the state field.');
}
if (!isset($userinfo['country']) || empty($userinfo['country'])) {
$userobj->transient = true;
$userobj->msg .= ' ' . gettext('You must supply the country field.');
}
if (!isset($userinfo['postal']) || empty($userinfo['postal'])) {
$userobj->transient = true;
$userobj->msg .= ' ' . gettext('You must supply the postal code field.');
}
}
zp_setCookie('reister_user_form_addresses', $_comment_form_save_post);
userAddressFields::setCustomData($userobj, $userinfo);
}
zp_apply_filter('register_user_registered', $userobj);
if ($userobj->transient) {
if (empty($_notify)) {
$_notify = 'filter';
}
} else {
$userobj->save();
if (MOD_REWRITE) {
$verify = '?verify=';
} else {
$verify = '&verify=';
}
//.........这里部分代码省略.........
示例11: tweetObject
/**
*
* Formats the message and calls sendTweet() on an object
* @param object $obj
*/
private static function tweetObject($obj)
{
if (getOption('multi_lingual')) {
$cur_locale = getUserLocale();
setupCurrentLocale(getOption('tweet_language'));
// the log will be in the language of the master user.
}
$error = '';
if (class_exists('tinyURL')) {
$link = tinyURL::getURL($obj);
} else {
$link = $obj->getLink();
}
switch ($type = $obj->table) {
case 'pages':
case 'news':
$error = self::composeStatus($link, $obj->getTitle(), $obj->getContent());
break;
case 'albums':
case 'images':
if ($type == 'images') {
$text = sprintf(gettext('New image: [%2$s]%1$s '), $item = $obj->getTitle(), $obj->imagefolder);
} else {
$text = sprintf(gettext('New album: %s '), $item = $obj->getTitle());
}
$error = self::composeStatus($link, '', $item);
break;
case 'comments':
$error = self::composeStatus($link, '', $obj->getComment());
break;
}
if (isset($cur_locale)) {
setupCurrentLocale($cur_locale);
// restore to whatever was in effect.
}
return $error;
}
示例12: print_language_string_list
/**
* Generates an editable list of language strings
*
* @param string $dbstring either a serialized languag string array or a single string
* @param string $name the prefix for the label, id, and name tags
* @param bool $textbox set to true for a textbox rather than a text field
* @param string $locale optional locale of the translation desired
* @param string $edit optional class
* @param int $wide column size. true or false for the standard or short sizes. Or pass a column size
* @param string $ulclass set to the class for the UL element
* @param int $rows set to the number of rows to show.
*/
function print_language_string_list($dbstring, $name, $textbox = false, $locale = NULL, $edit = '', $wide = TEXT_INPUT_SIZE, $ulclass = 'language_string_list', $rows = 6)
{
global $_zp_active_languages, $_zp_current_locale;
$dbstring = zpFunctions::unTagURLs($dbstring);
if (!empty($edit)) {
$edit = ' class="' . $edit . '"';
}
if (is_null($locale)) {
$locale = getUserLocale();
}
$strings = getSerializedArray($dbstring);
if (count($strings) == 1) {
$keys = array_keys($strings);
$lang = array_shift($keys);
if (!is_string($lang)) {
$strings = array($locale => array_shift($strings));
}
}
$activelang = generateLanguageList();
if (getOption('multi_lingual') && !empty($activelang)) {
if ($textbox) {
if (strpos($wide, '%') === false) {
$width = ' cols="' . $wide . '"';
} else {
$width = ' style="width:' . ((int) $wide - 1) . '%;"';
}
} else {
if (strpos($wide, '%') === false) {
$width = ' size="' . $wide . '"';
} else {
$width = ' style="width:' . ((int) $wide - 2) . '%;"';
}
}
// put the language list in perferred order
$preferred = array($_zp_current_locale);
foreach (parseHttpAcceptLanguage() as $lang) {
$preferred[] = str_replace('-', '_', $lang['fullcode']);
}
$preferred = array_unique($preferred);
$emptylang = array();
foreach ($preferred as $lang) {
foreach ($activelang as $key => $active) {
if ($active == $lang) {
$emptylang[$active] = $key;
unset($activelang[$key]);
continue 2;
}
}
if (strlen($lang) == 2) {
// "wild card language"
foreach ($activelang as $key => $active) {
if (substr($active, 0, 2) == $lang) {
$emptylang[$active] = $key;
}
}
}
}
foreach ($activelang as $key => $active) {
$emptylang[$active] = $key;
}
if ($textbox) {
$class = 'box';
} else {
$class = '';
}
echo '<ul class="' . $ulclass . $class . '"' . ">\n";
$empty = true;
foreach ($emptylang as $key => $lang) {
if (isset($strings[$key])) {
$string = $strings[$key];
if (!empty($string)) {
unset($emptylang[$key]);
$empty = false;
?>
<li>
<label for="<?php
echo $name . '_' . $key;
?>
"><?php
echo $lang;
?>
</label>
<?php
if ($textbox) {
echo "\n" . '<textarea name="' . $name . '_' . $key . '"' . $edit . $width . ' rows="' . $rows . '">' . html_encode($string) . '</textarea>';
} else {
echo '<br /><input id="' . $name . '_' . $key . '" name="' . $name . '_' . $key . '"' . $edit . ' type="text" value="' . html_encode($string) . '"' . $width . ' />';
}
//.........这里部分代码省略.........
示例13: printRegistrationForm
//.........这里部分代码省略.........
if (empty($admin_n)) {
$notify = 'incomplete';
}
if (isset($_POST['admin_email'])) {
$admin_e = trim(sanitize($_POST['admin_email']));
} else {
$admin_e = trim(sanitize($_POST['adminuser']));
}
if (!is_valid_email_zp($admin_e)) {
$notify = 'invalidemail';
}
$pass = trim(sanitize($_POST['adminpass']));
$user = trim(sanitize($_POST['adminuser']));
if (!empty($user) && !empty($admin_n) && !empty($admin_e)) {
if ($pass == trim(sanitize($_POST['adminpass_2']))) {
$currentadmin = $_zp_authority->getAnAdmin(array('`user`=' => $user, '`valid`>' => 0));
if (is_object($currentadmin)) {
$notify = 'exists';
}
if (empty($notify)) {
$notify = $_zp_authority->validatePassword($pass);
// test for valid password
if (empty($notify)) {
$userobj = $_zp_authority->newAdministrator('');
$userobj->transient = false;
$userobj->setUser($user);
$userobj->setPass($pass);
$userobj->setName($admin_n);
$userobj->setEmail($admin_e);
$userobj->setRights(0);
$userobj->setObjects(NULL);
$userobj->setGroup('');
$userobj->setCustomData('');
$userobj->setLanguage(getUserLocale());
zp_apply_filter('register_user_registered', $userobj);
if ($userobj->transient) {
if (empty($notify)) {
$notify = 'filter';
}
} else {
$userobj->save();
$link = rewrite_path(FULLWEBPATH . '/page/' . substr($_zp_gallery_page, 0, -4) . '?verify=' . bin2hex(serialize(array('user' => $user, 'email' => $admin_e))), FULLWEBPATH . '/index.php?p=' . substr($_zp_gallery_page, 0, -4) . '&verify=' . bin2hex(serialize(array('user' => $user, 'email' => $admin_e))), false);
$message = sprintf(get_language_string(getOption('register_user_text')), $link);
$notify = zp_mail(get_language_string(gettext('Registration confirmation')), $message, array($user => $admin_e));
if (empty($notify)) {
$notify = 'accepted';
}
}
}
}
} else {
$notify = 'mismatch';
}
} else {
$notify = 'incomplete';
}
}
if (zp_loggedin()) {
if (isset($_GET['userlog']) && $_GET['userlog'] == 1) {
echo '<meta http-equiv="refresh" content="1; url=' . WEBPATH . '/">';
} else {
echo '<div class="errorbox fade-message">';
echo '<h2>' . gettext("you are already logged in.") . '</h2>';
echo '</div>';
}
return;
示例14: print_language_string_list
/**
* Generates an editable list of language strings
*
* @param string $dbstring either a serialized languag string array or a single string
* @param string $name the prefix for the label, id, and name tags
* @param bool $textbox set to true for a textbox rather than a text field
* @param string $locale optional locale of the translation desired
* @param string $edit optional class
* @param int $wide column size. true or false for the standard or short sizes. Or pass a column size
* @param string $ulclass set to the class for the UL element
* @param int $rows set to the number of rows to show.
*/
function print_language_string_list($dbstring, $name, $textbox = false, $locale = NULL, $edit = '', $wide = TEXT_INPUT_SIZE, $ulclass = 'language_string_list', $rows = 6)
{
global $_zp_active_languages, $_zp_current_locale;
if (!empty($edit)) {
$edit = ' class="' . $edit . '"';
}
if (empty($id)) {
$groupid = '';
} else {
$groupid = ' id="' . $id . '"';
}
if (is_null($locale)) {
if (is_null($_zp_current_locale)) {
$_zp_current_locale = getUserLocale();
}
$locale = $_zp_current_locale;
}
if (preg_match('/^a:[0-9]+:{/', $dbstring)) {
$strings = unserialize($dbstring);
} else {
$strings = array($locale => $dbstring);
}
if (getOption('multi_lingual')) {
$emptylang = generateLanguageList();
$emptylang = array_flip($emptylang);
unset($emptylang['']);
if ($textbox) {
$class = 'box';
} else {
$class = '';
}
echo '<ul' . $groupid . ' class="' . $ulclass . $class . '"' . ">\n";
$empty = true;
foreach ($emptylang as $key => $lang) {
if (isset($strings[$key])) {
$string = $strings[$key];
if (!empty($string)) {
unset($emptylang[$key]);
$empty = false;
?>
<li>
<label for="<?php
echo $name . '_' . $key;
?>
"><?php
echo $lang;
?>
</label>
<?php
if ($textbox) {
echo "\n" . '<textarea name="' . $name . '_' . $key . '"' . $edit . ' cols="' . $wide . '" rows="' . $rows . '">' . html_encode($string) . '</textarea>';
} else {
echo '<br /><input id="' . $name . '_' . $key . '" name="' . $name . '_' . $key . '"' . $edit . ' type="text" value="' . html_encode($string) . '" size="' . $wide . '" />';
}
?>
</li>
<?php
}
}
}
if ($empty) {
$element = $emptylang[$locale];
unset($emptylang[$locale]);
$emptylang = array_merge(array($locale => $element), $emptylang);
}
foreach ($emptylang as $key => $lang) {
echo '<li><label for="' . $name . '_' . $key . '"></label>';
echo $lang;
if ($textbox) {
echo "\n" . '<textarea name="' . $name . '_' . $key . '"' . $edit . ' cols="' . $wide . '" rows="' . $rows . '"></textarea>';
} else {
echo '<br /><input id="' . $name . '_' . $key . '" name="' . $name . '_' . $key . '"' . $edit . ' type="text" value="" size="' . $wide . '" />';
}
echo "</li>\n";
}
echo "</ul>\n";
} else {
if (empty($locale)) {
$locale = 'en_US';
}
if (isset($strings[$locale])) {
$dbstring = $strings[$locale];
} else {
$dbstring = array_shift($strings);
}
if ($textbox) {
echo '<textarea' . $groupid . ' name="' . $name . '_' . $locale . '"' . $edit . ' cols="' . $wide . '" rows="' . $rows . '">' . html_encode($dbstring) . '</textarea>';
} else {
//.........这里部分代码省略.........
示例15: print_language_string_list
/**
* Generates an editable list of language strings
*
* @param string $dbstring either a serialized languag string array or a single string
* @param string $name the prefix for the label, id, and name tags
* @param bool $textbox set to true for a textbox rather than a text field
* @param string $locale optional locale of the translation desired
* @param string $edit optional class
* @param int $wide column size. true or false for the standard or short sizes. Or pass a column size
* @param string $ulclass set to the class for the UL element
* @param int $rows set to the number of rows to show.
*/
function print_language_string_list($dbstring, $name, $textbox = false, $locale = NULL, $edit = '', $wide = TEXT_INPUT_SIZE, $ulclass = 'language_string_list', $rows = 6)
{
global $_zp_active_languages, $_zp_current_locale, $_lsInstance;
$dbstring = zpFunctions::unTagURLs($dbstring);
if (!empty($edit)) {
$edit = ' class="' . $edit . '"';
}
if (is_null($locale)) {
$locale = getUserLocale();
}
$strings = getSerializedArray($dbstring);
if (count($strings) == 1) {
$keys = array_keys($strings);
$lang = array_shift($keys);
if (!is_string($lang)) {
$strings = array($locale => array_shift($strings));
}
}
$activelang = generateLanguageList();
$allLang = array_flip(generateLanguageList('all'));
foreach ($strings as $lang => $v) {
if (!array_key_exists($lang, $activelang)) {
$activelang[$allLang[$lang]] = $lang;
}
}
echo '<div id="ls_' . ++$_lsInstance . '">' . "\n";
if ($multi = getOption('multi_lingual') && !empty($activelang)) {
if ($textbox) {
if (strpos($wide, '%') === false) {
$width = ' cols="' . $wide . '"';
} else {
$width = ' style="width:' . ((int) $wide - 1) . '%;"';
}
} else {
if (strpos($wide, '%') === false) {
$width = ' size="' . $wide . '"';
} else {
$width = ' style="width:' . ((int) $wide - 2) . '%;"';
}
}
// put the language list in perferred order
$preferred = array();
if ($_zp_current_locale) {
$preferred[] = $_zp_current_locale;
}
foreach (parseHttpAcceptLanguage() as $lang) {
$preferred[] = str_replace('-', '_', $lang['fullcode']);
}
$preferred = array_unique($preferred);
$emptylang = array();
foreach ($preferred as $lang) {
foreach ($activelang as $key => $active) {
if ($active == $lang) {
$emptylang[$active] = $key;
unset($activelang[$key]);
continue 2;
}
}
if (strlen($lang) == 2) {
// "wild card language"
foreach ($activelang as $key => $active) {
if (substr($active, 0, 2) == $lang) {
$emptylang[$active] = $key;
}
}
}
}
foreach ($activelang as $key => $active) {
$emptylang[$active] = $key;
}
if ($textbox) {
$class = 'box';
} else {
$class = '';
}
echo '<ul id="ul_' . $_lsInstance . '" class="' . $ulclass . $class . '"' . ">\n";
$empty = true;
foreach ($emptylang as $key => $lang) {
if (isset($strings[$key])) {
$string = $strings[$key];
if (!empty($string)) {
unset($emptylang[$key]);
$empty = false;
?>
<li>
<label for="<?php
echo $name . '_' . $key;
?>
//.........这里部分代码省略.........