Exemplo n.º 1
0
function multi_configure()
{
    $lang_array = getLanguages();
    foreach ($lang_array as $lang) {
        $langOpt .= "<input type=\"checkbox\" name=\"langs[]\" value=\"{$lang}\"> {$lang} <br />";
    }
    echo <<<EOT
    <form action="{$_SERVER['REQUEST_URI']}" method="post">
        <p>
            Select the languages you want to use
        </p>
        <div style="margin:25;">
        <table border="0" cellspacing="0" cellpadding="0">
            <tr>
                {$langOpt}
            </tr>
        </table>
        </div>
        <span>
           <input type="submit" name="submit" value="Submit" /> &nbsp;&nbsp;&nbsp;
            <input type="button" name="cancel" onClick="window.location='pluginmgr.php';" value="Cancel" />
        </span>
    </form>
EOT;
}
Exemplo n.º 2
0
 public function getHTML()
 {
     $page = new Core_Template();
     // Login first
     $page->set('login', $this->getLogin());
     $page->set('title', $this->getTitle());
     $page->set('footer', $this->getFooter());
     $page->set('content', $this->getContent());
     $page->set('menu', $this->getMenu());
     // Order baskes
     $page->set('basket', $this->getBasket());
     $text = Core_Text::__getInstance();
     // Languages:
     $langs = getLanguages();
     foreach ($langs as $v) {
         $page->addListValue('languages', array($text->get($v[0], 'languages', 'main', $v[0]), self::getUrl('page=home&language=' . $v[1])));
     }
     $langs = getLayouts();
     foreach ($langs as $v) {
         $page->addListValue('layouts', array($text->get($v[0], 'layouts', 'main', $v[0]), self::getUrl('page=home&layout=' . $v[1])));
     }
     $page->set('languages', $text->get('languages', 'main', 'main'));
     $page->set('layouts', $text->get('layout', 'main', 'main'));
     $page->set('footerSpoof', $text->get('footer', 'main', 'main'));
     $page->set('printerFooter', $text->get('printerFooter', 'main', 'main'));
     $page->sortList('languages');
     $db = Core_Database::__getInstance();
     $page->set('mysqlCount', $db->getCounter());
     $page->set('order_url', array($text->get('shoplist', 'menu', 'main'), self::getUrl('page=order')));
     return $page->parse('index.tpl');
 }
Exemplo n.º 3
0
/**
 * Creates a list of all current installed languages
 *
 * @param string $lang_selected Defines the selected language
 */
function gen_def_language($lang_selected)
{
    $cfg = EasySCP_Registry::get('Config');
    $tpl = EasySCP_TemplateEngine::getInstance();
    $languages = getLanguages();
    foreach ($languages as $lang => $language_name) {
        $tpl->append(array('LANG_VALUE' => $lang, 'LANG_SELECTED' => $lang === $lang_selected ? $cfg->HTML_SELECTED : '', 'LANG_NAME' => tohtml($language_name)));
    }
}
Exemplo n.º 4
0
/**
 * Generate an elang title
 *
 * @param   object  $elang    E-Lang object
 * @param   array   $options  Array of options
 *
 * @return  string  String representation of the title
 *
 * @since  0.0.1
 */
function generateTitle($elang, $options)
{
    // Get all the languages
    $languages = getLanguages();
    // Get the page title
    if ($options['showlanguage']) {
        return sprintf(get_string('formatname', 'elang'), $elang->name, $languages[$elang->language]);
    } else {
        return $elang->name;
    }
}
Exemplo n.º 5
0
/**
 * Fetch the actual language information.
 *
 * What it does:
 * - Callback for $listOptions['get_items']['function'] in action_edit.
 * - Determines which languages are available by looking for the "index.{language}.php" file.
 * - Also figures out how many users are using a particular language.
 *
 * @package Languages
 */
function list_getLanguages()
{
    global $settings, $language, $txt;
    $db = database();
    $languages = array();
    // Keep our old entries.
    $old_txt = $txt;
    $backup_actual_theme_dir = $settings['actual_theme_dir'];
    $backup_base_theme_dir = !empty($settings['base_theme_dir']) ? $settings['base_theme_dir'] : '';
    // Override these for now.
    $settings['actual_theme_dir'] = $settings['base_theme_dir'] = $settings['default_theme_dir'];
    $all_languages = getLanguages();
    // Put them back.
    $settings['actual_theme_dir'] = $backup_actual_theme_dir;
    if (!empty($backup_base_theme_dir)) {
        $settings['base_theme_dir'] = $backup_base_theme_dir;
    } else {
        unset($settings['base_theme_dir']);
    }
    // Get the language files and data...
    foreach ($all_languages as $lang) {
        // Load the file to get the character set.
        require $lang['location'];
        $languages[$lang['filename']] = array('id' => $lang['filename'], 'count' => 0, 'char_set' => 'UTF-8', 'default' => $language == $lang['filename'] || $language == '' && $lang['filename'] == 'english', 'locale' => $txt['lang_locale'], 'name' => Util::ucwords(strtr($lang['filename'], array('_' => ' ', '-utf8' => ''))));
    }
    // Work out how many people are using each language.
    $request = $db->query('', '
		SELECT lngfile, COUNT(*) AS num_users
		FROM {db_prefix}members
		GROUP BY lngfile', array());
    while ($row = $db->fetch_assoc($request)) {
        // Default?
        if (empty($row['lngfile']) || !isset($languages[$row['lngfile']])) {
            $row['lngfile'] = $language;
        }
        if (!isset($languages[$row['lngfile']]) && isset($languages['english'])) {
            $languages['english']['count'] += $row['num_users'];
        } elseif (isset($languages[$row['lngfile']])) {
            $languages[$row['lngfile']]['count'] += $row['num_users'];
        }
    }
    $db->free_result($request);
    // Restore the current users language.
    $txt = $old_txt;
    // Return how many we have.
    return $languages;
}
function display_language_selectionform($formclass)
{
    if ($formclass != "") {
        ?>
        <form action='' method='POST' class="<?php 
        echo $formclass;
        ?>
">
        <label for="language-selector"></label>
        <?php 
    } else {
        ?>
        <form action='' method='POST'>
        <label for="language-selector"><?php 
        echo LANGUAGE_PROMPT;
        ?>
</label>
        <?php 
    }
    ?>

        <select name='language' id="language-selector">
          <?php 
    /* I've just specified a random list of possible languages; "Nonsense" is minimal and just there so you can see the login page switch around */
    $languages = getLanguages();
    //$languages = array('en-GB' => 'English', 'nl-NL' => 'Nederlands', 'en-XX' => 'Nonsense', 'fr-FR' => 'French', 'es-ES' => 'Spanish', 'it-IT' => 'Italian', 'ca-ES' => "Catalan");
    foreach ($languages as $key => $value) {
        $selected = '';
        if (isset($_SESSION['toolkits_language']) && $_SESSION['toolkits_language'] == $key) {
            $selected = " selected=selected ";
        }
        echo "<option value='{$key}' {$selected}>{$value}</option>\n";
    }
    ?>
        </select>
        <input type='submit' class="xerte_button" value='<?php 
    echo LANGUAGE_BUTTON_TEXT;
    ?>
' name='submit'/>
    </form>
<?php 
}
Exemplo n.º 7
0
 public function format_code($text, $post = null)
 {
     if (isset($post)) {
         $code = $text;
         if (preg_match("/\\[gist: ([0-9]+)\\]/i", $code, $matches)) {
             return '<script src="http://gist.github.com/' . $matches[1] . '.js"></script>';
         }
         $post->code_unformatted = $post->code;
         $languages = getLanguages();
         $geshi = new GeSHi($code, $languages[$post->language]);
         if ($geshi->error() !== false) {
             return "<pre id='geshi_code'>" . $geshi->error() . "</pre>";
         }
         $geshi->set_overall_id('geshi_code');
         $return = $geshi->parse_code();
         return $return;
     } else {
         return "<pre id='geshi_code'>" . $text . "</pre>";
     }
 }
function language_details($changed)
{
    global $xerte_toolkits_site;
    echo "<p>" . MANAGEMENT_LIBRARY_LANGUAGES_EXPLAINED . "</p>";
    echo "<p>" . MANAGEMENT_LIBRARY_ADD_LANGUAGE . "</p>";
    echo "<p><br><form method=\"post\" enctype=\"multipart/form-data\" id=\"languagepopup\" name=\"languageform\" target=\"upload_iframe\" action=\"website_code/php/language/import_language.php\" onsubmit=\"javascript:iframe_upload_language_check_initialise();\"><input name=\"filenameuploaded\" type=\"file\" /><br /><br/><button type=\"submit\" class=\"xerte_button\" name=\"submitBtn\" onsubmit=\"javascript:iframe_language_check_initialise()\" >" . MANAGEMENT_LIBRARY_LANGUAGE_INSTALL . "</button></form></p>";
    echo "<p>" . MANAGEMENT_LIBRARY_EXISTING_LANGUAGES . "</p>";
    $langs = getLanguages();
    $codes = array_keys($langs);
    echo "<ul>";
    foreach ($codes as $code) {
        echo "<li>" . $langs[$code];
        if ($code != "en-GB") {
            echo " <button type=\"button\" class=\"xerte_button\" onclick=\"javascript:delete_language('" . $code . "')\">" . MANAGEMENT_LIBRARY_REMOVE . " </button></li>";
        } else {
            echo "</li>";
        }
    }
    echo "</ul>";
    if ($changed) {
        echo "<p>" . MANAGEMENT_LIBRARY_LANGUAGES_UPDATED . "</p>";
    }
}
Exemplo n.º 9
0
function checkFirstLanguagesMessageFilesContainAllExistingMessages($messagesDirectoryName, $moduleName, $basePath)
{
    assert('is_string($messagesDirectoryName)');
    assert('is_dir   ($messagesDirectoryName)');
    $problems = array();
    $fileNamesToCategoriesToMessages = findFileNameToCategoryToMessage($messagesDirectoryName . '/..');
    $categoriesToMessagesToFileNames = convertFileNameToCategoryToMessageToCategoryToMessageToFileName($fileNamesToCategoriesToMessages);
    unset($categoriesToMessagesToFileNames['yii']);
    $languages = getLanguages($messagesDirectoryName);
    if (count($languages) > 0) {
        $firstLanguage = $languages[0];
        foreach ($categoriesToMessagesToFileNames as $category => $messagesToFileNames) {
            $existingMessages = array_keys(MessageUtil::getMessages($firstLanguage, $moduleName, $category));
            $duplicateCount = count($existingMessages) != count(array_unique($existingMessages));
            if ($duplicateCount != 0) {
                $problems[] = "{$moduleName} and its dependencies contain {$duplicateCount} duplicate entries.";
            }
            $yiiMessageFileName = "{$messagesDirectoryName}/{$firstLanguage}/{$category}.php";
            $yiiMessages = (require "{$basePath}/../../yii/framework/messages/{$firstLanguage}/yii.php");
            foreach ($messagesToFileNames as $message => $fileNames) {
                $fileNames = join(', ', $fileNames);
                if (!in_array($message, $existingMessages) && !in_array($message, $yiiMessages)) {
                    $problems[] = "'{$message}' in {$fileNames} not in {$firstLanguage}/{$category}.php in {$moduleName} or its dependencies.";
                } elseif (in_array($message, $existingMessages) && in_array($message, $yiiMessages)) {
                    $problems[] = "'{$message}' in {$fileNames} in {$firstLanguage}/{$category}.php in {$moduleName} or its dependencies is a duplicate of definition already in Yii.";
                }
            }
        }
    } else {
        $problems[] = 'No languages were found in the following directory:' . $messagesDirectoryName . "\n";
    }
    return $problems;
}
Exemplo n.º 10
0
                <td width="120px"><?php 
echo _t("Startpage");
?>
:</td>
                <td><select name="startapp"><?php 
echo makefileopts($apps, $wpref->startapp);
?>
</select></td>
            </tr>
            <tr>
                <td width="120px"><?php 
echo _t("Default language");
?>
:</td>
                <td><select name="language"><?php 
echo getLanguages($wpref->language);
?>
</select></td>
            </tr>
            <tr>
                <td><?php 
echo _t("No-Reply Email");
?>
:</td>
                <td><input name="email" type="text" value="<?php 
echo $wpref->noreply_email;
?>
" size="34" /></td>
            </tr>
            <tr>
                <td><label for="clean_url"><?php 
Exemplo n.º 11
0
 /**
  * Actually register the member.
  * @todo split this function in two functions:
  *  - a function that handles action=register2, which needs no parameter;
  *  - a function that processes the case of OpenID verification.
  *
  * @param bool $verifiedOpenID = false
  */
 public function action_register2($verifiedOpenID = false)
 {
     global $txt, $modSettings, $context, $user_info;
     // Start collecting together any errors.
     $reg_errors = Error_Context::context('register', 0);
     // We can't validate the token and the session with OpenID enabled.
     if (!$verifiedOpenID) {
         checkSession();
         if (!validateToken('register', 'post', true, false)) {
             $reg_errors->addError('token_verification');
         }
     }
     // Did we save some open ID fields?
     if ($verifiedOpenID && !empty($context['openid_save_fields'])) {
         foreach ($context['openid_save_fields'] as $id => $value) {
             $_POST[$id] = $value;
         }
     }
     // You can't register if it's disabled.
     if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) {
         fatal_lang_error('registration_disabled', false);
     }
     // If we're using an agreement checkbox, did they check it?
     if (!empty($modSettings['checkboxAgreement']) && !empty($_POST['checkbox_agreement'])) {
         $_SESSION['registration_agreed'] = true;
     }
     // Things we don't do for people who have already confirmed their OpenID allegances via register.
     if (!$verifiedOpenID) {
         // Well, if you don't agree, you can't register.
         if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) {
             redirectexit();
         }
         // Make sure they came from *somewhere*, have a session.
         if (!isset($_SESSION['old_url'])) {
             redirectexit('action=register');
         }
         // If we don't require an agreement, we need a extra check for coppa.
         if (empty($modSettings['requireAgreement']) && !empty($modSettings['coppaAge'])) {
             $_SESSION['skip_coppa'] = !empty($_POST['accept_agreement']);
         }
         // Are they under age, and under age users are banned?
         if (!empty($modSettings['coppaAge']) && empty($modSettings['coppaType']) && empty($_SESSION['skip_coppa'])) {
             loadLanguage('Login');
             fatal_lang_error('under_age_registration_prohibited', false, array($modSettings['coppaAge']));
         }
         // Check the time gate for miscreants. First make sure they came from somewhere that actually set it up.
         if (empty($_SESSION['register']['timenow']) || empty($_SESSION['register']['limit'])) {
             redirectexit('action=register');
         }
         // Failing that, check the time limit for exessive speed.
         if (time() - $_SESSION['register']['timenow'] < $_SESSION['register']['limit']) {
             loadLanguage('Login');
             $reg_errors->addError('too_quickly');
         }
         // Check whether the visual verification code was entered correctly.
         if (!empty($modSettings['reg_verification'])) {
             require_once SUBSDIR . '/VerificationControls.class.php';
             $verificationOptions = array('id' => 'register');
             $context['visual_verification'] = create_control_verification($verificationOptions, true);
             if (is_array($context['visual_verification'])) {
                 foreach ($context['visual_verification'] as $error) {
                     $reg_errors->addError($error);
                 }
             }
         }
     }
     foreach ($_POST as $key => $value) {
         if (!is_array($_POST[$key])) {
             $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key]));
         }
     }
     // Collect all extra registration fields someone might have filled in.
     $possible_strings = array('birthdate', 'time_format', 'buddy_list', 'pm_ignore_list', 'smiley_set', 'personal_text', 'avatar', 'lngfile', 'location', 'secret_question', 'secret_answer', 'website_url', 'website_title');
     $possible_ints = array('pm_email_notify', 'notify_types', 'id_theme', 'gender');
     $possible_floats = array('time_offset');
     $possible_bools = array('notify_announcements', 'notify_regularity', 'notify_send_body', 'hide_email', 'show_online');
     if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') {
         $_POST['secret_answer'] = md5($_POST['secret_answer']);
     }
     // Needed for isReservedName() and registerMember().
     require_once SUBSDIR . '/Members.subs.php';
     // Validation... even if we're not a mall.
     if (isset($_POST['real_name']) && (!empty($modSettings['allow_editDisplayName']) || allowedTo('moderate_forum'))) {
         $_POST['real_name'] = trim(preg_replace('~[\\t\\n\\r \\x0B\\0\\x{A0}\\x{AD}\\x{2000}-\\x{200F}\\x{201F}\\x{202F}\\x{3000}\\x{FEFF}]+~u', ' ', $_POST['real_name']));
         if (trim($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && Util::strlen($_POST['real_name']) < 60) {
             $possible_strings[] = 'real_name';
         }
     }
     // Handle a string as a birthdate...
     if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') {
         $_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate']));
     } elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) {
         $_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']);
     }
     // By default assume email is hidden, only show it if we tell it to.
     $_POST['hide_email'] = !empty($_POST['allow_email']) ? 0 : 1;
     // Validate the passed language file.
     if (isset($_POST['lngfile']) && !empty($modSettings['userLanguage'])) {
         // Do we have any languages?
         $context['languages'] = getLanguages();
         // Did we find it?
         if (isset($context['languages'][$_POST['lngfile']])) {
             $_SESSION['language'] = $_POST['lngfile'];
         } else {
             unset($_POST['lngfile']);
         }
     } else {
         unset($_POST['lngfile']);
     }
     // Some of these fields we may not want.
     if (!empty($modSettings['registration_fields'])) {
         // But we might want some of them if the admin asks for them.
         $standard_fields = array('location', 'gender');
         $reg_fields = explode(',', $modSettings['registration_fields']);
         $exclude_fields = array_diff($standard_fields, $reg_fields);
         // Website is a little different
         if (!in_array('website', $reg_fields)) {
             $exclude_fields = array_merge($exclude_fields, array('website_url', 'website_title'));
         }
         // We used to accept signature on registration but it's being abused by spammers these days, so no more.
         $exclude_fields[] = 'signature';
     } else {
         $exclude_fields = array('signature', 'location', 'gender', 'website_url', 'website_title');
     }
     $possible_strings = array_diff($possible_strings, $exclude_fields);
     $possible_ints = array_diff($possible_ints, $exclude_fields);
     $possible_floats = array_diff($possible_floats, $exclude_fields);
     $possible_bools = array_diff($possible_bools, $exclude_fields);
     // Set the options needed for registration.
     $regOptions = array('interface' => 'guest', 'username' => !empty($_POST['user']) ? $_POST['user'] : '', 'email' => !empty($_POST['email']) ? $_POST['email'] : '', 'password' => !empty($_POST['passwrd1']) ? $_POST['passwrd1'] : '', 'password_check' => !empty($_POST['passwrd2']) ? $_POST['passwrd2'] : '', 'openid' => !empty($_POST['openid_identifier']) ? $_POST['openid_identifier'] : '', 'auth_method' => !empty($_POST['authenticate']) ? $_POST['authenticate'] : '', 'check_reserved_name' => true, 'check_password_strength' => true, 'check_email_ban' => true, 'send_welcome_email' => !empty($modSettings['send_welcomeEmail']), 'require' => !empty($modSettings['coppaAge']) && !$verifiedOpenID && empty($_SESSION['skip_coppa']) ? 'coppa' : (empty($modSettings['registration_method']) ? 'nothing' : ($modSettings['registration_method'] == 1 ? 'activation' : 'approval')), 'extra_register_vars' => array(), 'theme_vars' => array());
     // Include the additional options that might have been filled in.
     foreach ($possible_strings as $var) {
         if (isset($_POST[$var])) {
             $regOptions['extra_register_vars'][$var] = Util::htmlspecialchars($_POST[$var], ENT_QUOTES);
         }
     }
     foreach ($possible_ints as $var) {
         if (isset($_POST[$var])) {
             $regOptions['extra_register_vars'][$var] = (int) $_POST[$var];
         }
     }
     foreach ($possible_floats as $var) {
         if (isset($_POST[$var])) {
             $regOptions['extra_register_vars'][$var] = (double) $_POST[$var];
         }
     }
     foreach ($possible_bools as $var) {
         if (isset($_POST[$var])) {
             $regOptions['extra_register_vars'][$var] = empty($_POST[$var]) ? 0 : 1;
         }
     }
     // Registration options are always default options...
     if (isset($_POST['default_options'])) {
         $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
     }
     $regOptions['theme_vars'] = isset($_POST['options']) && is_array($_POST['options']) ? $_POST['options'] : array();
     // Make sure they are clean, dammit!
     $regOptions['theme_vars'] = htmlspecialchars__recursive($regOptions['theme_vars']);
     // Check whether we have fields that simply MUST be displayed?
     require_once SUBSDIR . '/Profile.subs.php';
     loadCustomFields(0, 'register');
     foreach ($context['custom_fields'] as $row) {
         // Don't allow overriding of the theme variables.
         if (isset($regOptions['theme_vars'][$row['colname']])) {
             unset($regOptions['theme_vars'][$row['colname']]);
         }
         // Prepare the value!
         $value = isset($_POST['customfield'][$row['colname']]) ? trim($_POST['customfield'][$row['colname']]) : '';
         // We only care for text fields as the others are valid to be empty.
         if (!in_array($row['type'], array('check', 'select', 'radio'))) {
             // Is it too long?
             if ($row['field_length'] && $row['field_length'] < Util::strlen($value)) {
                 $reg_errors->addError(array('custom_field_too_long', array($row['name'], $row['field_length'])));
             }
             // Any masks to apply?
             if ($row['type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') {
                 // @todo We never error on this - just ignore it at the moment...
                 if ($row['mask'] == 'email' && !isValidEmail($value)) {
                     $reg_errors->addError(array('custom_field_invalid_email', array($row['name'])));
                 } elseif ($row['mask'] == 'number' && preg_match('~[^\\d]~', $value)) {
                     $reg_errors->addError(array('custom_field_not_number', array($row['name'])));
                 } elseif (substr($row['mask'], 0, 5) == 'regex' && trim($value) !== '' && preg_match(substr($row['mask'], 5), $value) === 0) {
                     $reg_errors->addError(array('custom_field_inproper_format', array($row['name'])));
                 }
             }
         }
         // Is this required but not there?
         if (trim($value) == '' && $row['show_reg'] > 1) {
             $reg_errors->addError(array('custom_field_empty', array($row['name'])));
         }
     }
     // Lets check for other errors before trying to register the member.
     if ($reg_errors->hasErrors()) {
         $_REQUEST['step'] = 2;
         // If they've filled in some details but made an error then they need less time to finish
         $_SESSION['register']['limit'] = 4;
         return $this->action_register();
     }
     // If they're wanting to use OpenID we need to validate them first.
     if (empty($_SESSION['openid']['verified']) && !empty($_POST['authenticate']) && $_POST['authenticate'] == 'openid') {
         // What do we need to save?
         $save_variables = array();
         foreach ($_POST as $k => $v) {
             if (!in_array($k, array('sc', 'sesc', $context['session_var'], 'passwrd1', 'passwrd2', 'regSubmit'))) {
                 $save_variables[$k] = $v;
             }
         }
         require_once SUBSDIR . '/OpenID.subs.php';
         $openID = new OpenID();
         $openID->validate($_POST['openid_identifier'], false, $save_variables);
     } elseif ($verifiedOpenID || (!empty($_POST['openid_identifier']) || !empty($_SESSION['openid']['openid_uri'])) && $_POST['authenticate'] == 'openid') {
         $regOptions['username'] = !empty($_POST['user']) && trim($_POST['user']) != '' ? $_POST['user'] : $_SESSION['openid']['nickname'];
         $regOptions['email'] = !empty($_POST['email']) && trim($_POST['email']) != '' ? $_POST['email'] : $_SESSION['openid']['email'];
         $regOptions['auth_method'] = 'openid';
         $regOptions['openid'] = !empty($_SESSION['openid']['openid_uri']) ? $_SESSION['openid']['openid_uri'] : (!empty($_POST['openid_identifier']) ? $_POST['openid_identifier'] : '');
     }
     // Registration needs to know your IP
     $req = request();
     $regOptions['ip'] = $user_info['ip'];
     $regOptions['ip2'] = $req->ban_ip();
     $memberID = registerMember($regOptions, 'register');
     // If there are "important" errors and you are not an admin: log the first error
     // Otherwise grab all of them and don't log anything
     if ($reg_errors->hasErrors(1) && !$user_info['is_admin']) {
         foreach ($reg_errors->prepareErrors(1) as $error) {
             fatal_error($error, 'general');
         }
     }
     // Was there actually an error of some kind dear boy?
     if ($reg_errors->hasErrors()) {
         $_REQUEST['step'] = 2;
         return $this->action_register();
     }
     // Do our spam protection now.
     spamProtection('register');
     // We'll do custom fields after as then we get to use the helper function!
     if (!empty($_POST['customfield'])) {
         require_once SUBSDIR . '/Profile.subs.php';
         makeCustomFieldChanges($memberID, 'register');
     }
     // If COPPA has been selected then things get complicated, setup the template.
     if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) {
         redirectexit('action=coppa;member=' . $memberID);
     } elseif (!empty($modSettings['registration_method'])) {
         loadTemplate('Register');
         $context += array('page_title' => $txt['register'], 'title' => $txt['registration_successful'], 'sub_template' => 'after', 'description' => $modSettings['registration_method'] == 2 ? $txt['approval_after_registration'] : $txt['activate_after_registration']);
     } else {
         call_integration_hook('integrate_activate', array($regOptions['username']));
         setLoginCookie(60 * $modSettings['cookieTime'], $memberID, hash('sha256', Util::strtolower($regOptions['username']) . $regOptions['password'] . $regOptions['register_vars']['password_salt']));
         redirectexit('action=auth;sa=check;member=' . $memberID, $context['server']['needs_login_fix']);
     }
 }
Exemplo n.º 12
0
function loadUserSettings()
{
    global $modSettings, $user_settings, $sourcedir;
    global $cookiename, $user_info, $language, $context;
    // Check first the integration, then the cookie, and last the session.
    if (count($integration_ids = HookAPI::callHook('integrate_verify_user')) > 0) {
        $id_member = 0;
        foreach ($integration_ids as $integration_id) {
            $integration_id = (int) $integration_id;
            if ($integration_id > 0) {
                $id_member = $integration_id;
                $already_verified = true;
                break;
            }
        }
    } else {
        $id_member = 0;
    }
    if (empty($id_member) && isset($_COOKIE[$cookiename])) {
        // Fix a security hole in PHP 4.3.9 and below...
        if (preg_match('~^a:[34]:\\{i:0;(i:\\d{1,6}|s:[1-8]:"\\d{1,8}");i:1;s:(0|40):"([a-fA-F0-9]{40})?";i:2;[id]:\\d{1,14};(i:3;i:\\d;)?\\}$~i', $_COOKIE[$cookiename]) == 1) {
            list($id_member, $password) = @unserialize($_COOKIE[$cookiename]);
            $id_member = !empty($id_member) && strlen($password) > 0 ? (int) $id_member : 0;
        } else {
            $id_member = 0;
        }
    } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) {
        // !!! Perhaps we can do some more checking on this, such as on the first octet of the IP?
        list($id_member, $password, $login_span) = @unserialize($_SESSION['login_' . $cookiename]);
        $id_member = !empty($id_member) && strlen($password) == 40 && $login_span > time() ? (int) $id_member : 0;
    }
    // Only load this stuff if the user isn't a guest.
    $_reload = $_to_cache = false;
    if ($id_member != 0) {
        // do we have a notification to dismiss (mark as seen) with this request? (we can only mark one per request, but that should be sufficient)
        if (isset($_REQUEST['nmdismiss']) && (int) $_REQUEST['nmdismiss'] > 0) {
            smf_db_query('UPDATE {db_prefix}log_notifications SET unread = 0 WHERE id_member = {int:id_user} AND id_act = {int:idact}', array('id_user' => $id_member, 'idact' => (int) $_REQUEST['nmdismiss']));
            $_reload = $_to_cache = true;
        }
        // Is the member data cached?
        if ($modSettings['cache_enable'] < 2 || ($user_settings = CacheAPI::getCache('user_settings-' . $id_member, 600)) == null) {
            $request = smf_db_query('
				SELECT mem.*, IFNULL(a.id_attach, 0) AS id_attach, a.filename, a.attachment_type
				FROM {db_prefix}members AS mem
					LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = {int:id_member})
				WHERE mem.id_member = {int:id_member}
				LIMIT 1', array('id_member' => $id_member));
            $user_settings = mysql_fetch_assoc($request);
            mysql_free_result($request);
        }
        // Did we find 'im?  If not, junk it.
        if (!empty($user_settings)) {
            // As much as the password should be right, we can assume the integration set things up.
            if (!empty($already_verified) && $already_verified === true) {
                $check = true;
            } elseif (strlen($password) == 40) {
                $check = sha1($user_settings['passwd'] . $user_settings['password_salt']) == $password;
            } else {
                $check = false;
            }
            // Wrong password or not activated - either way, you're going nowhere.
            $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? $user_settings['id_member'] : 0;
        } else {
            $id_member = 0;
        }
        // If we no longer have the member maybe they're being all hackey, stop brute force!
        if (!$id_member) {
            require_once $sourcedir . '/LogInOut.php';
            validatePasswordFlood(!empty($user_settings['id_member']) ? $user_settings['id_member'] : $id_member, !empty($user_settings['passwd_flood']) ? $user_settings['passwd_flood'] : false, $id_member != 0);
        }
    }
    // Found 'im, let's set up the variables.
    if ($id_member != 0) {
        // Let's not update the last visit time in these cases...
        // 1. SSI doesn't count as visiting the forum.
        // 2. RSS feeds and XMLHTTP requests don't count either.
        // 3. If it was set within this session, no need to set it again.
        // 4. New session, yet updated < five hours ago? Maybe cache can help.
        if (SMF != 'SSI' && !isset($_REQUEST['xml']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != '.xml') && empty($_SESSION['id_msg_last_visit']) && (empty($modSettings['cache_enable']) || ($_SESSION['id_msg_last_visit'] = CacheAPI::getCache('user_last_visit-' . $id_member, 5 * 3600)) === null)) {
            // Do a quick query to make sure this isn't a mistake.
            $result = smf_db_query('
				SELECT poster_time
				FROM {db_prefix}messages
				WHERE id_msg = {int:id_msg}
				LIMIT 1', array('id_msg' => $user_settings['id_msg_last_visit']));
            list($visitTime) = mysql_fetch_row($result);
            mysql_free_result($result);
            $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit'];
            // If it was *at least* five hours ago...
            if ($visitTime < time() - 5 * 3600) {
                updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']));
                $user_settings['last_login'] = time();
                if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
                    CacheAPI::putCache('user_settings-' . $id_member, $user_settings, 60);
                }
                if (!empty($modSettings['cache_enable'])) {
                    CacheAPI::putCache('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600);
                }
            }
        } elseif (empty($_SESSION['id_msg_last_visit'])) {
            $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit'];
        }
        $username = $user_settings['member_name'];
        if (empty($user_settings['additional_groups'])) {
            $user_info = array('groups' => array($user_settings['id_group'], $user_settings['id_post_group']));
        } else {
            $user_info = array('groups' => array_merge(array($user_settings['id_group'], $user_settings['id_post_group']), explode(',', $user_settings['additional_groups'])));
        }
        // Because history has proven that it is possible for groups to go bad - clean up in case.
        foreach ($user_info['groups'] as $k => $v) {
            $user_info['groups'][$k] = (int) $v;
        }
        // This is a logged in user, so definitely not a spider.
        $user_info['possibly_robot'] = false;
        $user_info['show_online'] = $user_settings['show_online'];
        $user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset'];
    } else {
        // This is what a guest's variables should be.
        $username = '';
        $user_info = array('groups' => array(-1));
        $user_settings = array();
        if (isset($_COOKIE[$cookiename])) {
            $_COOKIE[$cookiename] = '';
        }
        // Do we perhaps think this is a search robot? Check every five minutes just in case...
        if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) {
            $user_info['possibly_robot'] = SpiderCheck();
        } elseif (!empty($modSettings['spider_mode'])) {
            $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0;
        } else {
            $ci_user_agent = strtolower($_SERVER['HTTP_USER_AGENT']);
            $user_info['possibly_robot'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla') === false && strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') === false || strpos($ci_user_agent, 'googlebot') !== false || strpos($ci_user_agent, 'slurp') !== false || strpos($ci_user_agent, 'crawl') !== false;
        }
        $user_info['time_offset'] = isset($_SESSION['tzoffset']) ? $_SESSION['tzoffset'] : 0;
        $user_info['guest_need_tzoffset'] = !isset($_SESSION['tzoffset']);
        // don't have it yet, embed the js to determine tz offset for *guests only*
    }
    // Set up the $user_info array.
    $user_info += array('id' => $id_member, 'username' => $username, 'name' => isset($user_settings['real_name']) ? $user_settings['real_name'] : '', 'email' => isset($user_settings['email_address']) ? $user_settings['email_address'] : '', 'passwd' => isset($user_settings['passwd']) ? $user_settings['passwd'] : '', 'language' => empty($user_settings['lngfile']) || empty($modSettings['userLanguage']) ? $language : $user_settings['lngfile'], 'is_guest' => $id_member == 0, 'is_admin' => in_array(1, $user_info['groups']), 'theme' => empty($user_settings['id_theme']) ? 0 : $user_settings['id_theme'], 'last_login' => empty($user_settings['last_login']) ? 0 : $user_settings['last_login'], 'ip' => $_SERVER['REMOTE_ADDR'], 'ip2' => $_SERVER['BAN_CHECK_IP'], 'posts' => empty($user_settings['posts']) ? 0 : $user_settings['posts'], 'time_format' => empty($user_settings['time_format']) ? $modSettings['time_format'] : $user_settings['time_format'], 'avatar' => array('url' => isset($user_settings['avatar']) ? $user_settings['avatar'] : '', 'filename' => empty($user_settings['filename']) ? '' : $user_settings['filename'], 'custom_dir' => !empty($user_settings['attachment_type']) && $user_settings['attachment_type'] == 1, 'id_attach' => isset($user_settings['id_attach']) ? $user_settings['id_attach'] : 0), 'smiley_set' => isset($user_settings['smiley_set']) ? $user_settings['smiley_set'] : '', 'messages' => empty($user_settings['instant_messages']) ? 0 : $user_settings['instant_messages'], 'unread_messages' => empty($user_settings['unread_messages']) ? 0 : $user_settings['unread_messages'], 'total_time_logged_in' => empty($user_settings['total_time_logged_in']) ? 0 : $user_settings['total_time_logged_in'], 'buddies' => !empty($modSettings['enable_buddylist']) && !empty($user_settings['buddy_list']) ? explode(',', $user_settings['buddy_list']) : array(), 'ignoreboards' => !empty($user_settings['ignore_boards']) && !empty($modSettings['allow_ignore_boards']) ? explode(',', $user_settings['ignore_boards']) : array(), 'ignoreusers' => !empty($user_settings['pm_ignore_list']) ? explode(',', $user_settings['pm_ignore_list']) : array(), 'warning' => isset($user_settings['warning']) ? $user_settings['warning'] : 0, 'likesgiven' => isset($user_settings['likes_given']) ? $user_settings['likes_given'] : 0, 'likesreceived' => isset($user_settings['likes_received']) ? $user_settings['likes_received'] : 0, 'permissions' => array(), 'act_optout' => isset($user_settings['act_optout']) ? $user_settings['act_optout'] : '', 'notify_optout' => isset($user_settings['notify_optout']) ? $user_settings['notify_optout'] : '', 'meta' => !empty($user_settings['meta']) ? @unserialize($user_settings['meta']) : array());
    $user_info['smf_sidebar_disabled'] = 0;
    $user_info['groups'] = array_unique($user_info['groups']);
    // Make sure that the last item in the ignore boards array is valid.  If the list was too long it could have an ending comma that could cause problems.
    if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) {
        unset($user_info['ignoreboards'][$tmp]);
    }
    // Do we have any languages to validate this?
    if (!empty($modSettings['userLanguage']) && (!empty($_GET['language']) || !empty($_SESSION['language']))) {
        $languages = getLanguages();
    }
    // Allow the user to change their language if its valid.
    if (!empty($modSettings['userLanguage']) && !empty($_GET['language']) && isset($languages[strtr($_GET['language'], './\\:', '____')])) {
        $user_info['language'] = strtr($_GET['language'], './\\:', '____');
        $_SESSION['language'] = $user_info['language'];
    } elseif (!empty($modSettings['userLanguage']) && !empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) {
        $user_info['language'] = strtr($_SESSION['language'], './\\:', '____');
    }
    // map language to a numeric id
    $n = 0;
    if (isset($context['languages'])) {
        foreach ($context['languages'] as $key => $lang) {
            if ($key == $user_info['language']) {
                break;
            }
            $n++;
        }
    }
    $user_info['language_id'] = $n + 1;
    // Just build this here, it makes it easier to change/use - administrators can see all boards.
    if ($user_info['is_admin']) {
        $user_info['query_see_board'] = '1=1';
    } else {
        $user_info['query_see_board'] = '(FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0' . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')';
    }
    // Build the list of boards they WANT to see.
    // This will take the place of query_see_boards in certain spots, so it better include the boards they can see also
    // If they aren't ignoring any boards then they want to see all the boards they can see
    if (empty($user_info['ignoreboards'])) {
        $user_info['query_wanna_see_board'] = $user_info['query_see_board'];
    } else {
        $user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))';
    }
    /*
     * figure out unread notifications
     * 
     * the reason why this is here in an extra query is that we need query_see_board.
     * e.g. when a user gets a notification for a topic that has been moved to a board he
     * is not permitted to access, we want to filter out the notifications.
     */
    if ($id_member != 0 && (!isset($user_settings['notify_count']) || $_reload)) {
        // this is actually cached, unless $user_settings was re-fetched from the db.
        $_to_cache = true;
        $request = smf_db_query('
					SELECT COUNT(n.id_act) AS notify_count FROM {db_prefix}log_notifications AS n
						LEFT JOIN {db_prefix}log_activities AS a ON (a.id_act = n.id_act)
						LEFT JOIN {db_prefix}boards AS b ON(b.id_board = a.id_board)
						WHERE n.id_member = {int:id_member} AND n.unread = 1 AND ' . (!empty($user_info['ignoreusers']) ? 'a.id_member NOT IN({array_int:ignoredusers}) AND ' : '') . ' ({query_wanna_see_board} OR a.id_board = 0)', array('id_member' => $id_member, 'ignoredusers' => $user_info['ignoreusers']));
        if (mysql_num_rows($request) > 0) {
            list($unread) = mysql_fetch_row($request);
            $user_settings['notify_count'] = $unread;
        } else {
            $user_settings['notify_count'] = 0;
        }
        mysql_free_result($request);
    }
    if ($modSettings['cache_enable'] >= 2 && $id_member != 0 && $_to_cache) {
        CacheAPI::putCache('user_settings-' . $id_member, $user_settings, 600);
    }
    $user_info['notify_count'] = isset($user_settings['notify_count']) ? $user_settings['notify_count'] : 0;
    if ($user_info['unread_messages'] && $user_info['notify_count'] == 0) {
        $user_info['notify_count']++;
    }
    // record the user in the list of users who were online today. todo: there should be an option for this feature.
    if (!empty($modSettings['who_track_daily_visitors']) && $user_info['id'] > 0 && !isset($modSettings['online_today'][$user_info['id']])) {
        $modSettings['online_today'][$user_info['id']] = array('name' => $user_info['name'], 'show_online' => $user_info['show_online'], 'link' => '<a class="member group_' . (empty($user_settings['id_group']) ? $user_settings['id_post_group'] : $user_settings['id_group']) . '" href="' . URL::user($user_info['id'], $user_info['name']) . '">' . $user_info['name'] . '</a>');
        updateSettings(array('log_online_today' => @serialize($modSettings['online_today'])));
    }
    $user_info['font_class'] = isset($_COOKIE['EOS_Fontstyle']) ? $_COOKIE['EOS_Fontstyle'] : '0';
    HookAPI::callHook('load_userdata', array(&$user_info, &$user_settings));
}
Exemplo n.º 13
0
<?php

/**
 *	Site settings
 **************************/
/* verify that user is admin */
checkAdmin();
/* fetch all settings */
$settings = getAllSettings();
/* get all languages */
$langs = getLanguages();
?>

<!-- title -->
<h4><?php 
print _('phpIPAM Server settings');
?>
</h4>
<hr>

<form name="settings" id="settings">
<table id="settings" class="table table-hover table-condensed table-top">

<!-- site settings -->
<tr class="settings-title">
	<th colspan="3"><h4><?php 
print _('Site settings');
?>
</h4></th>
</tr>
Exemplo n.º 14
0
function ModifyLanguageSettings($return_config = false)
{
    global $scripturl, $context, $txt, $boarddir, $settings, $smcFunc;
    // Warn the user if the backup of Settings.php failed.
    $settings_not_writable = !is_writable($boarddir . '/Settings.php');
    $settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
    /* If you're writing a mod, it's a bad idea to add things here....
    	For each option:
    		variable name, description, type (constant), size/possible values, helptext.
    	OR	an empty string for a horizontal rule.
    	OR	a string for a titled section. */
    $config_vars = array('language' => array('language', $txt['default_language'], 'file', 'select', array(), null, 'disabled' => $settings_not_writable), array('userLanguage', $txt['userLanguage'], 'db', 'check', null, 'userLanguage'));
    if ($return_config) {
        return $config_vars;
    }
    // Get our languages. No cache and use utf8.
    getLanguages(false, false);
    foreach ($context['languages'] as $lang) {
        $config_vars['language'][4][$lang['filename']] = array($lang['filename'], strtr($lang['name'], array('-utf8' => ' (UTF-8)')));
    }
    // Saving settings?
    if (isset($_REQUEST['save'])) {
        checkSession();
        saveSettings($config_vars);
        redirectexit('action=admin;area=languages;sa=settings');
    }
    // Setup the template stuff.
    $context['post_url'] = $scripturl . '?action=admin;area=languages;sa=settings;save';
    $context['settings_title'] = $txt['language_settings'];
    $context['save_disabled'] = $settings_not_writable;
    if ($settings_not_writable) {
        $context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br />';
    } elseif ($settings_backup_fail) {
        $context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br />';
    }
    // Fill the config array.
    prepareServerSettingsContext($config_vars);
}
Exemplo n.º 15
0
 /**
  * Admin panel interface to manage the anti spam question area
  *
  * @return mixed[]
  */
 public function settings()
 {
     global $txt, $context, $language;
     // Load any question and answers!
     $filter = null;
     if (isset($_GET['language'])) {
         $filter = array('type' => 'language', 'value' => $_GET['language']);
     }
     $context['question_answers'] = $this->_loadAntispamQuestions($filter);
     $languages = getLanguages();
     // Languages dropdown only if we have more than a lang installed, otherwise is plain useless
     if (count($languages) > 1) {
         $context['languages'] = $languages;
         foreach ($context['languages'] as &$lang) {
             if ($lang['filename'] === $language) {
                 $lang['selected'] = true;
             }
         }
     }
     // Saving them?
     if (isset($_GET['save'])) {
         // Handle verification questions.
         $questionInserts = array();
         $count_questions = 0;
         foreach ($_POST['question'] as $id => $question) {
             $question = trim(Util::htmlspecialchars($question, ENT_COMPAT));
             $answers = array();
             $question_lang = isset($_POST['language'][$id]) && isset($languages[$_POST['language'][$id]]) ? $_POST['language'][$id] : $language;
             if (!empty($_POST['answer'][$id])) {
                 foreach ($_POST['answer'][$id] as $answer) {
                     $answer = trim(Util::strtolower(Util::htmlspecialchars($answer, ENT_COMPAT)));
                     if ($answer != '') {
                         $answers[] = $answer;
                     }
                 }
             }
             // Already existed?
             if (isset($context['question_answers'][$id])) {
                 $count_questions++;
                 // Changed?
                 if ($question == '' || empty($answers)) {
                     $this->_delete($id);
                     $count_questions--;
                 } else {
                     $this->_update($id, $question, $answers, $question_lang);
                 }
             } elseif ($question != '' && !empty($answers)) {
                 $questionInserts[] = array('question' => $question, 'answer' => serialize($answers), 'language' => $question_lang);
                 $count_questions++;
             }
         }
         // Any questions to insert?
         if (!empty($questionInserts)) {
             $this->_insert($questionInserts);
         }
         if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) {
             $_POST['qa_verification_number'] = $count_questions;
         }
     }
     return array(array('title', 'setup_verification_questions'), array('desc', 'setup_verification_questions_desc'), array('int', 'qa_verification_number', 'postinput' => $txt['setting_qa_verification_number_desc']), array('callback', 'question_answer_list'));
 }
Exemplo n.º 16
0
/**
 * Form on user edit page
 * @param $FH FormHandler of the page
 * @param $mode add or edit mode
 */
function _base_baseEdit($FH, $mode)
{
    $uid = $FH->getArrayOrPostValue("uid");
    $f = new DivForModule(_("User attributes"), "#F4F4F4");
    $f->push(new Table());
    if ($mode == "add") {
        $loginTpl = new InputTpl("uid", '/^[a-zA-Z0-9][A-Za-z0-9_.\\-]*$/');
    } else {
        $loginTpl = new HiddenTpl("uid");
    }
    $f->add(new TrFormElement(_("Login") . "*", $loginTpl), array("value" => $uid));
    /*if($mode == "edit") {
          $lastlog = get_last_log_user($uid);
          if ($lastlog[0] != 0) {
          	$f->add(
          	    new LinkTrFormElement(_("Last action"), new HiddenTpl("lastaction")),
                  array("value" => urlStr("base/users/loguser", array("user" => $uid)), "name" => $lastlog[1][0]["date"])
              );
          }
      }*/
    $f->add(new TrFormElement(_("Password") . "*", new PasswordTpl("pass")), array("value" => ""));
    $f->add(new TrFormElement(_("Confirm password") . "*", new PasswordTpl("confpass")), array("value" => ""));
    $f->add(new TrFormElement(_("Photo"), new ImageTpl("jpegPhoto")), array("value" => $FH->getArrayOrPostValue("jpegPhoto"), "action" => $mode));
    $f->add(new TrFormElement(_("Last name") . "*", new InputTpl("sn")), array("value" => $FH->getArrayOrPostValue("sn")));
    $f->add(new TrFormElement(_("First name") . "*", new InputTpl("givenName")), array("value" => $FH->getArrayOrPostValue("givenName")));
    $f->add(new TrFormElement(_("Title") . "*", new InputTpl("title")), array("value" => $FH->getArrayOrPostValue("title")));
    $f->add(new TrFormElement(_("Email address"), new MailInputTpl("mail")), array("value" => $FH->getArrayOrPostValue("mail")));
    $f->pop();
    $phoneregexp = "/^[a-zA-Z0-9(/ +\\-]*\$/";
    $tn = new MultipleInputTpl("telephoneNumber", _("Telephone number"));
    $tn->setRegexp($phoneregexp);
    $f->add(new FormElement(_("Telephone number"), $tn), $FH->getArrayOrPostValue("telephoneNumber", "array"));
    $f->push(new Table());
    $f->add(new TrFormElement(_("Mobile number"), new InputTpl("mobile", $phoneregexp)), array("value" => $FH->getArrayOrPostValue("mobile")));
    $f->add(new TrFormElement(_("Fax number"), new InputTpl("facsimileTelephoneNumber", $phoneregexp)), array("value" => $FH->getArrayOrPostValue("facsimileTelephoneNumber")));
    $f->add(new TrFormElement(_("Home phone number"), new InputTpl("homePhone", $phoneregexp)), array("value" => $FH->getArrayOrPostValue("homePhone")));
    $languages = new SelectItem("preferredLanguage");
    $labels = array(_("Choose language")) + array_values(getLanguages());
    $values = array("") + array_keys(getLanguages());
    $languages->setElements($labels);
    $languages->setElementsVal($values);
    $f->add(new TrFormElement(_("Preferred language"), $languages), array("value" => $FH->getArrayOrPostValue("preferredLanguage")));
    $checked = "checked";
    if ($FH->getArrayOrPostValue("loginShell") != '/bin/false') {
        $checked = "";
    }
    $f->add(new TrFormElement(_("Disable user's shell"), new CheckboxTpl("isBaseDesactive"), array("tooltip" => _("A disabled user can't log in any UNIX services.<br/>\n                                  His login shell command is replaced by /bin/false"))), array("value" => $checked));
    /* Primary group */
    $groupsTpl = new SelectItem("primary");
    $all_groups = search_groups();
    $groups = array();
    foreach ($all_groups as $key => $infos) {
        $groups[] = $infos[0];
    }
    $groupsTpl->setElements($groups);
    if ($mode == "add") {
        $primary = getUserDefaultPrimaryGroup();
    } else {
        if ($mode == "edit") {
            /* In case of error, display the POST values */
            if ($FH->isUpdated("primary")) {
                $primary = $FH->getValue("primary");
            } else {
                $primary = getUserPrimaryGroup($uid);
                /* If the group is not an LDAP group */
                if (!in_array($primary, $groups)) {
                    $primaryGroups = $groups;
                    $primaryGroups[] = $primary;
                    $groupsTpl->setElements($primaryGroups);
                }
            }
        }
    }
    $f->add(new TrFormElement(_("Primary group"), $groupsTpl), array("value" => $primary));
    /* Secondary groups */
    $groupsTpl = new MembersTpl("secondary");
    $groupsTpl->setTitle(_("User's groups"), _("All groups"));
    // get the user's groups
    /* In case of error, display the POST values */
    if ($FH->getPostValue("secondary")) {
        $user_groups = $FH->getPostValue("secondary");
    } else {
        if ($mode == 'edit') {
            $user_groups = getUserSecondaryGroups($uid);
        } else {
            $user_groups = array();
        }
    }
    $member = array();
    foreach ($user_groups as $group) {
        $member[$group] = $group;
    }
    // get all groups
    $available = array();
    foreach ($groups as $group) {
        if (!in_array($group, $member)) {
            $available[$group] = $group;
        }
    }
    $f->add(new TrFormElement(_("Secondary groups"), $groupsTpl), array("member" => $member, "available" => $available));
    $f->pop();
    $f->push(new DivExpertMode());
    $f->push(new Table());
    $f->add(new TrFormElement(_("Home directory"), new InputTpl("homeDirectory")), array("value" => $FH->getArrayOrPostValue("homeDirectory")));
    if ($mode == "add") {
        $f->add(new TrFormElement(_("Create home directory on filesystem"), new CheckboxTpl("createHomeDir")), array("value" => "checked"));
        $f->add(new TrFormElement(_("Force to use the home directory if it exists"), new CheckboxTpl("ownHomeDir"), array("tooltip" => _("Warning: an existing directory may belong to another user !"))), array("value" => ""));
    }
    $f->add(new TrFormElement(_("Login shell"), new InputTpl("loginShell")), array("value" => $FH->getArrayOrPostValue("loginShell")));
    $f->add(new TrFormElement(_("Common name"), new InputTpl("cn"), array("tooltip" => _("This field is used by some LDAP clients (for example Thunderbird address book) to display user entries."))), array("value" => $FH->getArrayOrPostValue("cn")));
    $f->add(new TrFormElement(_("Preferred name to be used"), new InputTpl("displayName"), array("tooltip" => _("This field is used by SAMBA (and other LDAP clients) to display user name."))), array("value" => $FH->getArrayOrPostValue("displayName")));
    if ($mode == "edit") {
        $f->add(new TrFormElement(_("UID"), new HiddenTpl("uidNumber")), array("value" => $FH->getArrayOrPostValue("uidNumber")));
        $f->add(new TrFormElement(_("GID"), new HiddenTpl("gidNumber")), array("value" => $FH->getArrayOrPostValue("gidNumber")));
    }
    $f->pop();
    $f->pop();
    return $f;
}
Exemplo n.º 17
0
/**
 * Load all the languages for the profile.
 */
function profileLoadLanguages()
{
    global $context;
    $context['profile_languages'] = array();
    // Get our languages!
    $languages = getLanguages();
    // Setup our languages.
    foreach ($languages as $lang) {
        $context['profile_languages'][$lang['filename']] = $lang['name'];
    }
    ksort($context['profile_languages']);
    // Return whether we should proceed with this.
    return count($context['profile_languages']) > 1 ? true : false;
}
Exemplo n.º 18
0
        }
        ?>
/><input type="submit" name="deleteBtn" value="<?php 
        echo translate('Delete');
        ?>
" disabled="disabled"/><input type="button" value="<?php 
        echo translate('Cancel');
        ?>
" onclick="closeWindow();"/>
        </div>
      </form>

<?php 
    } else {
        if ($tab == "system") {
            $configCats[$tab]['ZM_LANG_DEFAULT']['Hint'] = join('|', getLanguages());
            $configCats[$tab]['ZM_SKIN_DEFAULT']['Hint'] = join('|', $skin_options);
            $configCats[$tab]['ZM_CSS_DEFAULT']['Hint'] = join('|', array_map('basename', glob('skins/' . ZM_SKIN_DEFAULT . '/css/*', GLOB_ONLYDIR)));
        }
        ?>
      <form name="optionsForm" method="post" action="<?php 
        echo $_SERVER['PHP_SELF'];
        ?>
">
        <input type="hidden" name="view" value="<?php 
        echo $view;
        ?>
"/>
        <input type="hidden" name="tab" value="<?php 
        echo $tab;
        ?>
Exemplo n.º 19
0
 function updateDetail($color_pattern_id, $customer_id, $name, $description, $default_color_id = '')
 {
     $logger = new logger('class', 'ColorPattern');
     //prepare parameter data
     $color_pattern_id = tep_db_prepare_input($color_pattern_id);
     $customer_id = tep_db_prepare_input($customer_id);
     $default_color_id = tep_db_prepare_input($default_color_id);
     if (substr($default_color_id, 0, 1) == '#' && strlen($default_color_id) > 1) {
         $color_code = strtoupper(str_replace('#', '', $default_color_id));
         $q = tep_db_query("SELECT color_id FROM color WHERE color_code='{$color_code}'");
         if (tep_db_num_rows($q) > 0) {
             $r = tep_db_fetch_array($q);
             $default_color_id = $r['color_id'];
         } else {
             $default_color_id = '';
         }
     }
     $name = $this->setName($name);
     $description = $this->setDescription($description);
     $error_message = array();
     //handle update into color_pattern
     $sql_data_array_cp = array('customers_id' => $customer_id);
     if ($default_color_id != '') {
         $sql_data_array_cp['default_color_id'] = $default_color_id;
     }
     $result_cp = tep_db_perform('color_pattern', $sql_data_array_cp, 'update', "color_pattern_id = {$color_pattern_id}");
     if (!$result_cp) {
         $logger->write("Failed to update table color_pattern");
     }
     //handle update into color_pattern_description
     //first check if record exist, will insert if none yet, and update if exist
     if (is_array($name) and is_array($description)) {
         $languages = getLanguages();
         foreach ($languages as $x => $lang) {
             $sql_data_array_cpd = array('name' => $name[$x], 'description' => $description[$x]);
             if (is_dataExist("color_pattern_description", "name", "color_pattern_id={$color_pattern_id} AND languages_id={$x}")) {
                 $result_cpd[$x] = tep_db_perform('color_pattern_description', $sql_data_array_cpd, 'update', "color_pattern_id = {$color_pattern_id} AND languages_id = {$x}");
             } else {
                 $sql_data_array_cpd["color_pattern_id"] = $color_pattern_id;
                 $sql_data_array_cpd["languages_id"] = $x;
                 $result_cpd[$x] = tep_db_perform('color_pattern_description', $sql_data_array_cpd);
             }
             if (!$result_cpd[$x]) {
                 $logger->write("Failed to update table color_pattern_description language_id {$x}");
             }
         }
     } else {
         global $lang;
         $x = $lang;
         $sql_data_array_cpd = array('name' => $name, 'description' => $description);
         if (is_dataExist("color_pattern_description", "name", "color_pattern_id={$color_pattern_id} AND languages_id={$x}")) {
             $result_cpd = tep_db_perform('color_pattern_description', $sql_data_array_cpd, 'update', "color_pattern_id = {$color_pattern_id} AND languages_id = {$x}");
         } else {
             $sql_data_array_cpd["color_pattern_id"] = $color_pattern_id;
             $sql_data_array_cpd["languages_id"] = $x;
             $result_cpd = tep_db_perform('color_pattern_description', $sql_data_array_cpd);
         }
         if (!$result_cpd) {
             $logger->write("Failed to update table color_pattern_description languages_id {$x}");
         }
     }
     //handle process result report
     $processResult = array('error_message' => $error_message, 'result_cp' => $result_cp, 'result_cpd' => $result_cpd);
     $processResult = $this->parseReturn($processResult);
     $logger->close();
     return $processResult;
 }
Exemplo n.º 20
0
function language($n)
{
    $x = getLanguages();
    return $x[$n];
}
Exemplo n.º 21
0
function loadUserSettings()
{
    global $modSettings, $user_settings, $sourcedir, $smcFunc;
    global $cookiename, $user_info, $language;
    // Check first the integration, then the cookie, and last the session.
    if (count($integration_ids = call_integration_hook('integrate_verify_user')) > 0) {
        $id_member = 0;
        foreach ($integration_ids as $integration_id) {
            $integration_id = (int) $integration_id;
            if ($integration_id > 0) {
                $id_member = $integration_id;
                $already_verified = true;
                break;
            }
        }
    } else {
        $id_member = 0;
    }
    if (empty($id_member) && isset($_COOKIE[$cookiename])) {
        // Fix a security hole in PHP 4.3.9 and below...
        if (preg_match('~^a:[34]:\\{i:0;(i:\\d{1,6}|s:[1-8]:"\\d{1,8}");i:1;s:(0|40):"([a-fA-F0-9]{40})?";i:2;[id]:\\d{1,14};(i:3;i:\\d;)?\\}$~i', $_COOKIE[$cookiename]) == 1) {
            list($id_member, $password) = @unserialize($_COOKIE[$cookiename]);
            $id_member = !empty($id_member) && strlen($password) > 0 ? (int) $id_member : 0;
        } else {
            $id_member = 0;
        }
    } elseif (empty($id_member) && isset($_SESSION['login_' . $cookiename]) && ($_SESSION['USER_AGENT'] == $_SERVER['HTTP_USER_AGENT'] || !empty($modSettings['disableCheckUA']))) {
        // !!! Perhaps we can do some more checking on this, such as on the first octet of the IP?
        list($id_member, $password, $login_span) = @unserialize($_SESSION['login_' . $cookiename]);
        $id_member = !empty($id_member) && strlen($password) == 40 && $login_span > time() ? (int) $id_member : 0;
    }
    // Only load this stuff if the user isn't a guest.
    if ($id_member != 0) {
        // Is the member data cached?
        if (empty($modSettings['cache_enable']) || $modSettings['cache_enable'] < 2 || ($user_settings = cache_get_data('user_settings-' . $id_member, 60)) == null) {
            $request = $smcFunc['db_query']('', '
				SELECT mem.*, IFNULL(a.id_attach, 0) AS id_attach, a.filename, a.attachment_type
				FROM {db_prefix}members AS mem
					LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = {int:id_member})
				WHERE mem.id_member = {int:id_member}
				LIMIT 1', array('id_member' => $id_member));
            $user_settings = $smcFunc['db_fetch_assoc']($request);
            $smcFunc['db_free_result']($request);
            if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
                cache_put_data('user_settings-' . $id_member, $user_settings, 60);
            }
        }
        // Did we find 'im?  If not, junk it.
        if (!empty($user_settings)) {
            // As much as the password should be right, we can assume the integration set things up.
            if (!empty($already_verified) && $already_verified === true) {
                $check = true;
            } elseif (strlen($password) == 40) {
                $check = sha1($user_settings['passwd'] . $user_settings['password_salt']) == $password;
            } else {
                $check = false;
            }
            // Wrong password or not activated - either way, you're going nowhere.
            $id_member = $check && ($user_settings['is_activated'] == 1 || $user_settings['is_activated'] == 11) ? $user_settings['id_member'] : 0;
        } else {
            $id_member = 0;
        }
        // If we no longer have the member maybe they're being all hackey, stop brute force!
        if (!$id_member) {
            require_once $sourcedir . '/LogInOut.php';
            validatePasswordFlood(!empty($user_settings['id_member']) ? $user_settings['id_member'] : $id_member, !empty($user_settings['passwd_flood']) ? $user_settings['passwd_flood'] : false, $id_member != 0);
        }
    }
    // Found 'im, let's set up the variables.
    if ($id_member != 0) {
        // Let's not update the last visit time in these cases...
        // 1. SSI doesn't count as visiting the forum.
        // 2. RSS feeds and XMLHTTP requests don't count either.
        // 3. If it was set within this session, no need to set it again.
        // 4. New session, yet updated < five hours ago? Maybe cache can help.
        if (SMF != 'SSI' && !isset($_REQUEST['xml']) && (!isset($_REQUEST['action']) || $_REQUEST['action'] != '.xml') && empty($_SESSION['id_msg_last_visit']) && (empty($modSettings['cache_enable']) || ($_SESSION['id_msg_last_visit'] = cache_get_data('user_last_visit-' . $id_member, 5 * 3600)) === null)) {
            // Do a quick query to make sure this isn't a mistake.
            $result = $smcFunc['db_query']('', '
				SELECT poster_time
				FROM {db_prefix}messages
				WHERE id_msg = {int:id_msg}
				LIMIT 1', array('id_msg' => $user_settings['id_msg_last_visit']));
            list($visitTime) = $smcFunc['db_fetch_row']($result);
            $smcFunc['db_free_result']($result);
            $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit'];
            // If it was *at least* five hours ago...
            if ($visitTime < time() - 5 * 3600) {
                updateMemberData($id_member, array('id_msg_last_visit' => (int) $modSettings['maxMsgID'], 'last_login' => time(), 'member_ip' => $_SERVER['REMOTE_ADDR'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']));
                $user_settings['last_login'] = time();
                if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2) {
                    cache_put_data('user_settings-' . $id_member, $user_settings, 60);
                }
                if (!empty($modSettings['cache_enable'])) {
                    cache_put_data('user_last_visit-' . $id_member, $_SESSION['id_msg_last_visit'], 5 * 3600);
                }
            }
        } elseif (empty($_SESSION['id_msg_last_visit'])) {
            $_SESSION['id_msg_last_visit'] = $user_settings['id_msg_last_visit'];
        }
        $username = $user_settings['member_name'];
        if (empty($user_settings['additional_groups'])) {
            $user_info = array('groups' => array($user_settings['id_group'], $user_settings['id_post_group']));
        } else {
            $user_info = array('groups' => array_merge(array($user_settings['id_group'], $user_settings['id_post_group']), explode(',', $user_settings['additional_groups'])));
        }
        // Because history has proven that it is possible for groups to go bad - clean up in case.
        foreach ($user_info['groups'] as $k => $v) {
            $user_info['groups'][$k] = (int) $v;
        }
        // This is a logged in user, so definitely not a spider.
        $user_info['possibly_robot'] = false;
    } else {
        // This is what a guest's variables should be.
        $username = '';
        $user_info = array('groups' => array(-1));
        $user_settings = array();
        if (isset($_COOKIE[$cookiename])) {
            $_COOKIE[$cookiename] = '';
        }
        // Do we perhaps think this is a search robot? Check every five minutes just in case...
        if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) {
            require_once $sourcedir . '/ManageSearchEngines.php';
            $user_info['possibly_robot'] = SpiderCheck();
        } elseif (!empty($modSettings['spider_mode'])) {
            $user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0;
        } else {
            $ci_user_agent = strtolower($_SERVER['HTTP_USER_AGENT']);
            $user_info['possibly_robot'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla') === false && strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') === false || strpos($ci_user_agent, 'googlebot') !== false || strpos($ci_user_agent, 'slurp') !== false || strpos($ci_user_agent, 'crawl') !== false;
        }
    }
    // Set up the $user_info array.
    $user_info += array('id' => $id_member, 'username' => $username, 'name' => isset($user_settings['real_name']) ? $user_settings['real_name'] : '', 'email' => isset($user_settings['email_address']) ? $user_settings['email_address'] : '', 'passwd' => isset($user_settings['passwd']) ? $user_settings['passwd'] : '', 'language' => empty($user_settings['lngfile']) || empty($modSettings['userLanguage']) ? $language : $user_settings['lngfile'], 'is_guest' => $id_member == 0, 'is_admin' => in_array(1, $user_info['groups']), 'theme' => empty($user_settings['id_theme']) ? 0 : $user_settings['id_theme'], 'last_login' => empty($user_settings['last_login']) ? 0 : $user_settings['last_login'], 'ip' => $_SERVER['REMOTE_ADDR'], 'ip2' => $_SERVER['BAN_CHECK_IP'], 'posts' => empty($user_settings['posts']) ? 0 : $user_settings['posts'], 'time_format' => empty($user_settings['time_format']) ? $modSettings['time_format'] : $user_settings['time_format'], 'time_offset' => empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset'], 'avatar' => array('url' => isset($user_settings['avatar']) ? $user_settings['avatar'] : '', 'filename' => empty($user_settings['filename']) ? '' : $user_settings['filename'], 'custom_dir' => !empty($user_settings['attachment_type']) && $user_settings['attachment_type'] == 1, 'id_attach' => isset($user_settings['id_attach']) ? $user_settings['id_attach'] : 0), 'smiley_set' => isset($user_settings['smiley_set']) ? $user_settings['smiley_set'] : '', 'messages' => empty($user_settings['instant_messages']) ? 0 : $user_settings['instant_messages'], 'unread_messages' => empty($user_settings['unread_messages']) ? 0 : $user_settings['unread_messages'], 'total_time_logged_in' => empty($user_settings['total_time_logged_in']) ? 0 : $user_settings['total_time_logged_in'], 'buddies' => !empty($modSettings['enable_buddylist']) && !empty($user_settings['buddy_list']) ? explode(',', $user_settings['buddy_list']) : array(), 'ignoreboards' => !empty($user_settings['ignore_boards']) && !empty($modSettings['allow_ignore_boards']) ? explode(',', $user_settings['ignore_boards']) : array(), 'ignoreusers' => !empty($user_settings['pm_ignore_list']) ? explode(',', $user_settings['pm_ignore_list']) : array(), 'warning' => isset($user_settings['warning']) ? $user_settings['warning'] : 0, 'permissions' => array());
    $user_info['groups'] = array_unique($user_info['groups']);
    // Make sure that the last item in the ignore boards array is valid.  If the list was too long it could have an ending comma that could cause problems.
    if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) {
        unset($user_info['ignoreboards'][$tmp]);
    }
    // Do we have any languages to validate this?
    if (!empty($modSettings['userLanguage']) && (!empty($_GET['language']) || !empty($_SESSION['language']))) {
        $languages = getLanguages();
    }
    // Allow the user to change their language if its valid.
    if (!empty($modSettings['userLanguage']) && !empty($_GET['language']) && isset($languages[strtr($_GET['language'], './\\:', '____')])) {
        $user_info['language'] = strtr($_GET['language'], './\\:', '____');
        $_SESSION['language'] = $user_info['language'];
    } elseif (!empty($modSettings['userLanguage']) && !empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) {
        $user_info['language'] = strtr($_SESSION['language'], './\\:', '____');
    }
    // Just build this here, it makes it easier to change/use - administrators can see all boards.
    if ($user_info['is_admin']) {
        $user_info['query_see_board'] = '1=1';
    } else {
        $user_info['query_see_board'] = '(FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0' . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')';
    }
    // Build the list of boards they WANT to see.
    // This will take the place of query_see_boards in certain spots, so it better include the boards they can see also
    // If they aren't ignoring any boards then they want to see all the boards they can see
    if (empty($user_info['ignoreboards'])) {
        $user_info['query_wanna_see_board'] = $user_info['query_see_board'];
    } else {
        $user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))';
    }
}
Exemplo n.º 22
0
function showPageHeader($HeaderString)
{
    global $officialDatabaseName;
    // these variables are defined in 'ini.inc.php'
    global $hostInstitutionAbbrevName;
    global $hostInstitutionName;
    global $hostInstitutionURL;
    global $helpResourcesURL;
    global $logoImageURL;
    global $logoImageWidth;
    global $logoImageHeight;
    global $loginWelcomeMsg;
    // these variables are globally defined in function 'showLogin()' in 'include.inc.php'
    global $loginStatus;
    global $loginLinks;
    global $displayType;
    global $query;
    global $queryURL;
    global $showQuery;
    global $showLinks;
    global $showRows;
    global $citeStyle;
    global $citeOrder;
    global $loc;
    // '$loc' is made globally available in 'core.php'
    ?>

<table class="pageheader" align="center" width="95%" summary="This holds the title logo and info">
<tr>
	<td rowspan="2" align="left" width="<?php 
    echo $logoImageWidth + 26;
    ?>
"><a href="<?php 
    echo $hostInstitutionURL;
    ?>
"><img src="<?php 
    echo $logoImageURL;
    ?>
" border="0" alt="<?php 
    echo encodeHTML($hostInstitutionAbbrevName);
    ?>
 Home" title="<?php 
    echo encodeHTML($hostInstitutionName);
    ?>
" width="<?php 
    echo $logoImageWidth;
    ?>
" height="<?php 
    echo $logoImageHeight;
    ?>
"></a></td>
	<td width="60%">
		<h4><?php 
    echo encodeHTML($officialDatabaseName);
    ?>
</h4>
        <p><?php 
    echo $HeaderString;
    ?>
</p>
		<span class="smallup">
			<a href="index.php"<?php 
    echo addAccessKey("attribute", "home");
    ?>
 title="<?php 
    echo $loc["LinkTitle_Home"] . addAccessKey("title", "home");
    ?>
"><?php 
    echo $loc["Home"];
    ?>
</a>&nbsp;|&nbsp;
			<a href="show.php?records=all"<?php 
    echo addAccessKey("attribute", "show_all");
    ?>
 title="<?php 
    echo $loc["LinkTitle_ShowAll"] . addAccessKey("title", "show_all");
    ?>
"><?php 
    echo $loc["ShowAll"];
    ?>
</a>&nbsp;|&nbsp;
			<a href="simple_search.php"<?php 
    echo addAccessKey("attribute", "search");
    ?>
 title="<?php 
    echo $loc["LinkTitle_SimpleSearch"] . addAccessKey("title", "search");
    ?>
"><?php 
    echo $loc["SimpleSearch"];
    ?>
</a>&nbsp;|&nbsp;
			<a href="advanced_search.php"<?php 
    echo addAccessKey("attribute", "adv_search");
    ?>
 title="<?php 
    echo $loc["LinkTitle_AdvancedSearch"] . addAccessKey("title", "adv_search");
    ?>
"><?php 
    echo $loc["AdvancedSearch"];
    ?>
</a><?php 
    // -------------------------------------------------------
    if (isset($_SESSION['user_permissions']) and preg_match("/allow_add/", $_SESSION['user_permissions'])) {
        // ... include a link to 'record.php?recordAction=add...':
        ?>

			&nbsp;|&nbsp;<a href="record.php?recordAction=add"<?php 
        echo addAccessKey("attribute", "add");
        ?>
 title="<?php 
        echo $loc["LinkTitle_AddRecord"] . addAccessKey("title", "add");
        ?>
"><?php 
        echo $loc["AddRecord"];
        ?>
</a><?php 
    }
    // -------------------------------------------------------
    if (isset($_SESSION['user_permissions']) and preg_match("/allow_import|allow_batch_import/", $_SESSION['user_permissions'])) {
        // ... include a link to 'import.php':
        ?>

			&nbsp;|&nbsp;<a href="import.php"<?php 
        echo addAccessKey("attribute", "import");
        ?>
 title="<?php 
        echo $loc["LinkTitle_Import"] . addAccessKey("title", "import");
        ?>
"><?php 
        echo $loc["Import"];
        ?>
</a><?php 
    }
    // -------------------------------------------------------
    ?>

		</span>
	</td>
	<td class="small" rowspan="2" align="right">
		<div id="loginInfo" style="text-align: right">
            <div id="loginStatus" style="margin: 5px 0">
                <?php 
    echo $loginStatus;
    ?>
 <?php 
    echo $loginWelcomeMsg ? ' - ' . $loginWelcomeMsg : '';
    ?>
            </div>
			<div id="loginLinks" style="margin: 5px 0">
                <?php 
    echo $loginLinks;
    ?>
            </div>
            <?php 
    if (!isset($_SESSION['loginEmail'])) {
        // Display Options:
        // Get all languages that were setup and enabled by the admin:
        $languagesArray = getLanguages("");
        // function 'getLanguages()' is defined in 'include.inc.php'
        $languageOptionTags = buildSelectMenuOptions($languagesArray, "/ *; */", "\t\t\t", true);
        // build properly formatted <option> tag elements from language items returned by function 'getLanguages()'
        ?>
                <div id="language" style="margin: 5px 0">
                    <form action="select_language.php" method="post">
                        <div class="row collapse">
                            <div class="small-10 columns">
                                <select name="language_id">
                                    <option value="">-- Language --</option>
                                    <?php 
        echo $languageOptionTags;
        ?>
                                </select>
                            </div>
                            <div class="small-2 columns">
                                <button type="submit" class="button secondary tiny">Select</button>
                            </div>
                        </div>
                    </form>
                </div>
            <?php 
    }
    ?>
		</div>
		<div id="queryrefs">
            <?php 
    echo buildQuickSearchElements($query, $queryURL, $showQuery, $showLinks, $showRows, $citeStyle, $citeOrder, $displayType);
    ?>
		</div>
	</td>
</tr>
</table>
<?php 
}
Exemplo n.º 23
0
        return $response->withJson(array("status" => 0, "Id" => $language['id'], "Name" => $language['name']));
    } else {
        $response->withJson(array("status" => 1, "message" => "Language Id {$args['id']} does not exists"));
    }
});
// select all cities usind id wia ajax (service handler)
$app->get("/cities/{id}/", function ($request, $response, $args) use($link) {
    //$post=$request->getParsedBody();
    $output = getCities($args['id']);
    $response->getBody()->write($output['options']);
    return $response;
});
// select all languages usind id wia ajax (service handler)
$app->get("/languages/{id}/", function ($request, $response, $args) use($link) {
    //$post=$request->getParsedBody();
    $output = getLanguages($args['id']);
    $response->getBody()->write($output['options']);
    return $response;
});
/* Edit country using Id */
$app->put("/country/{id}/", function ($request, $response, $args) use($link) {
    $put = $request->getParsedBody();
    $name = clearStr($put['Name']);
    $id = getId($args['id'], 'countries');
    if ($id && updateId($id['id'], 'countries', $name)) {
        return $response->withJson(array('status' => 1, 'message' => "Country updated sucsesfully", 'name' => $name, 'put' => $put));
    } else {
        return $response->withJson(array('status' => 0, 'message' => "Country ID  does not exists"));
    }
});
/* Edit city using Id */
Exemplo n.º 24
0
function profileLoadLanguages()
{
    global $context, $modSettings, $settings, $cur_profile, $language, $smcFunc;
    $context['profile_languages'] = array();
    // Get our languages!
    getLanguages(true, true);
    // Setup our languages.
    foreach ($context['languages'] as $lang) {
        $context['profile_languages'][$lang['filename']] = strtr($lang['name'], array('-utf8' => ''));
    }
    ksort($context['profile_languages']);
    // Return whether we should proceed with this.
    return count($context['profile_languages']) > 1 ? true : false;
}
Exemplo n.º 25
0
function EditAgreement()
{
    global $txt, $boarddir, $context, $modSettings, $smcFunc, $settings;
    // By default we look at agreement.txt.
    $context['current_agreement'] = '';
    // Is there more than one to edit?
    $context['editable_agreements'] = array('' => $txt['admin_agreement_default']);
    // Get our languages.
    getLanguages();
    // Try to figure out if we have more agreements.
    foreach ($context['languages'] as $lang) {
        if (file_exists($boarddir . '/agreement.' . $lang['filename'] . '.txt')) {
            $context['editable_agreements']['.' . $lang['filename']] = $lang['name'];
            // Are we editing this?
            if (isset($_POST['agree_lang']) && $_POST['agree_lang'] == '.' . $lang['filename']) {
                $context['current_agreement'] = '.' . $lang['filename'];
            }
        }
    }
    if (isset($_POST['agreement'])) {
        checkSession();
        // Off it goes to the agreement file.
        $fp = fopen($boarddir . '/agreement' . $context['current_agreement'] . '.txt', 'w');
        fwrite($fp, str_replace("\r", '', $_POST['agreement']));
        fclose($fp);
        updateSettings(array('requireAgreement' => !empty($_POST['requireAgreement'])));
    }
    $context['agreement'] = file_exists($boarddir . '/agreement' . $context['current_agreement'] . '.txt') ? htmlspecialchars(file_get_contents($boarddir . '/agreement' . $context['current_agreement'] . '.txt')) : '';
    $context['warning'] = is_writable($boarddir . '/agreement' . $context['current_agreement'] . '.txt') ? '' : $txt['agreement_not_writable'];
    $context['require_agreement'] = !empty($modSettings['requireAgreement']);
    $context['sub_template'] = 'edit_agreement';
    $context['page_title'] = $txt['registration_agreement'];
}
Exemplo n.º 26
0
                <fieldset>
                    <legend><?php 
echo _t("Additional");
?>
</legend>
                    <table width="100%">
                        <tr>
                            <td width="150px">
                                <?php 
echo _t("Language");
?>
 :
                            </td>
                            <td>
                                <select name="language"><?php 
echo getLanguages($acl->language);
?>
</select>
                            </td>
                        </tr>
                        <tr>
                            <td width="150px">
                                <?php 
echo _t("Anonymous");
?>
 :
                            </td>
                            <td>
                                <input type="checkbox" name="anonymous" <?php 
echo $acl->anonymous ? "CHECKED" : "";
?>
Exemplo n.º 27
0
            <td>
                <?php 
foreach ($actions as $name => $files) {
    echo "<select id='actions_{$name}' name='actions_{$name}' class='nav_action' style='display:none;'>" . str_replace(".php", "", makefileopts($files[0])) . "</select>";
}
?>
            </td>
        </tr>
        <tr>
            <td><?php 
echo _t("Language");
?>
</td>
            <td>
                <select name="language"><?php 
echo getLanguages();
?>
</select>
            </td>
        </tr>
        <tr>
            <td><input type="submit" name="create" value="<?php 
echo _t("Create item");
?>
" /></td>
        </tr>
    </table>
</form>

<script type="text/javascript">
    $(document).ready(function(){
Exemplo n.º 28
0
 function getLanguagesInput($lang = null, $name = "language", $input = "radio")
 {
     $languages = getLanguages(true);
     $HTML = null;
     if ($input === "select") {
         $HTML = '<select id="language" name="' . $name . '" size="1">';
     }
     foreach ($languages as $language) {
         if (!isset($checked)) {
             if (!is_null($lang)) {
                 if ($lang === $language["name"]) {
                     $check = $input === "radio" ? ' checked="checked"' : ' selected="selected"';
                     $checked = true;
                 } else {
                     $check = null;
                 }
             } else {
                 if ($language["default"] === true) {
                     $check = $input === "radio" ? ' checked="checked"' : ' selected="selected"';
                     $checked = true;
                 }
             }
         }
         $show = isset($check) ? $check : null;
         if ($input === "radio") {
             $HTML .= ' <input id="language" name="' . $name . '" type="radio" value="' . $language["name"] . '" ' . $show . ' /> ' . $language["value"] . ' ';
         } elseif ($input === "select") {
             $HTML .= ' <option value="' . $language["name"] . '"' . $show . '>' . __($language["name"]) . '</option>';
         }
         unset($check);
     }
     if ($input === "select") {
         $HTML .= '</select>';
     }
     return $HTML;
 }
Exemplo n.º 29
0
function comboProductsDescriptionImprovedStatus($id, $name = '', $value = '', $class = '', $html_params = '', $empty_value_text = '')
{
    $navoptions = '<select id="' . $id . '"';
    if ($name != '') {
        $navoptions .= ' name="' . $name . '"';
    }
    if ($class != '') {
        $navoptions .= ' class="' . $class . '"';
    }
    if ($html_params != '') {
        $navoptions .= ' ' . $html_params;
    }
    $navoptions .= '>';
    $selected = $value == '' ? 'selected="selected"' : '';
    $text_value = 'Please select status...';
    $empty_value_text == '' ? $text_value : ($text_value = $empty_value_text);
    $navoptions .= '<option value="" ' . $selected . '>' . $text_value . '</option>';
    $languages = getLanguages();
    $improved_status = array('1' => ' - improved', '0' => ' - not yet improved');
    foreach ($languages as $lid => $lval) {
        foreach ($improved_status as $imp_id => $imp_val) {
            $navoptions .= '<option value="' . $imp_id . '&#39; AND pd.language_id=&#39;' . $lid . '"' . ($value == $lid ? 'selected="selected"' : '') . '>' . $lval . $imp_val . '</option>';
        }
    }
    $navoptions .= '</select>';
    return $navoptions;
}
Exemplo n.º 30
0
function Register2($verifiedOpenID = false)
{
    global $txt, $modSettings, $context, $sourcedir;
    // Start collecting together any errors.
    $reg_errors = array();
    // Did we save some open ID fields?
    if ($verifiedOpenID && !empty($context['openid_save_fields'])) {
        foreach ($context['openid_save_fields'] as $id => $value) {
            $_POST[$id] = $value;
        }
    }
    // You can't register if it's disabled.
    if (!empty($modSettings['registration_method']) && $modSettings['registration_method'] == 3) {
        fatal_lang_error('registration_disabled', false);
    }
    // Things we don't do for people who have already confirmed their OpenID allegances via register.
    if (!$verifiedOpenID) {
        // Well, if you don't agree, you can't register.
        if (!empty($modSettings['requireAgreement']) && empty($_SESSION['registration_agreed'])) {
            redirectexit();
        }
        // Make sure they came from *somewhere*, have a session.
        if (!isset($_SESSION['old_url'])) {
            redirectexit('action=register');
        }
        // Are they under age, and under age users are banned?
        if (!empty($modSettings['coppaAge']) && empty($modSettings['coppaType']) && empty($_SESSION['skip_coppa'])) {
            // !!! This should be put in Errors, imho.
            loadLanguage('Login');
            fatal_lang_error('under_age_registration_prohibited', false, array($modSettings['coppaAge']));
        }
        // Check whether the visual verification code was entered correctly.
        if (!empty($modSettings['reg_verification'])) {
            require_once $sourcedir . '/lib/Subs-Editor.php';
            $verificationOptions = array('id' => 'register');
            $context['visual_verification'] = create_control_verification($verificationOptions, true);
            if (is_array($context['visual_verification'])) {
                loadLanguage('Errors');
                foreach ($context['visual_verification'] as $error) {
                    $reg_errors[] = $txt['error_' . $error];
                }
            }
        }
    }
    foreach ($_POST as $key => $value) {
        if (!is_array($_POST[$key])) {
            $_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key]));
        }
    }
    // Collect all extra registration fields someone might have filled in.
    $possible_strings = array('location', 'birthdate', 'time_format', 'buddy_list', 'pm_ignore_list', 'smiley_set', 'signature', 'personal_text', 'avatar', 'lngfile', 'secret_question', 'secret_answer');
    $possible_ints = array('pm_email_notify', 'notify_types', 'gender', 'id_theme');
    $possible_floats = array('time_offset');
    $possible_bools = array('notify_announcements', 'notify_regularity', 'notify_send_body', 'hide_email', 'show_online');
    if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') {
        $_POST['secret_answer'] = md5($_POST['secret_answer']);
    }
    // Needed for isReservedName() and registerMember().
    require_once $sourcedir . '/lib/Subs-Members.php';
    // Validation... even if we're not a mall.
    if (isset($_POST['real_name']) && (!empty($modSettings['allow_editDisplayName']) || allowedTo('moderate_forum'))) {
        $_POST['real_name'] = trim(preg_replace('~[\\s]~u', ' ', $_POST['real_name']));
        if (trim($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && commonAPI::strlen($_POST['real_name']) < 60) {
            $possible_strings[] = 'real_name';
        }
    }
    // Handle a string as a birthdate...
    if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') {
        $_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate']));
    } elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) {
        $_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']);
    }
    // By default assume email is hidden, only show it if we tell it to.
    $_POST['hide_email'] = !empty($_POST['allow_email']) ? 0 : 1;
    // Validate the passed language file.
    if (isset($_POST['lngfile']) && !empty($modSettings['userLanguage'])) {
        // Do we have any languages?
        if (empty($context['languages'])) {
            getLanguages();
        }
        // Did we find it?
        if (isset($context['languages'][$_POST['lngfile']])) {
            $_SESSION['language'] = $_POST['lngfile'];
        } else {
            unset($_POST['lngfile']);
        }
    } else {
        unset($_POST['lngfile']);
    }
    // Set the options needed for registration.
    $regOptions = array('interface' => 'guest', 'username' => !empty($_POST['user']) ? $_POST['user'] : '', 'email' => !empty($_POST['email']) ? $_POST['email'] : '', 'password' => !empty($_POST['passwrd1']) ? $_POST['passwrd1'] : '', 'password_check' => !empty($_POST['passwrd2']) ? $_POST['passwrd2'] : '', 'openid' => !empty($_POST['openid_identifier']) ? $_POST['openid_identifier'] : '', 'auth_method' => !empty($_POST['authenticate']) ? $_POST['authenticate'] : '', 'check_reserved_name' => true, 'check_password_strength' => true, 'check_email_ban' => true, 'send_welcome_email' => !empty($modSettings['send_welcomeEmail']), 'require' => !empty($modSettings['coppaAge']) && !$verifiedOpenID && empty($_SESSION['skip_coppa']) ? 'coppa' : (empty($modSettings['registration_method']) ? 'nothing' : ($modSettings['registration_method'] == 1 ? 'activation' : 'approval')), 'extra_register_vars' => array(), 'theme_vars' => array());
    // Include the additional options that might have been filled in.
    foreach ($possible_strings as $var) {
        if (isset($_POST[$var])) {
            $regOptions['extra_register_vars'][$var] = commonAPI::htmlspecialchars($_POST[$var], ENT_QUOTES);
        }
    }
    foreach ($possible_ints as $var) {
        if (isset($_POST[$var])) {
            $regOptions['extra_register_vars'][$var] = (int) $_POST[$var];
        }
    }
    foreach ($possible_floats as $var) {
        if (isset($_POST[$var])) {
            $regOptions['extra_register_vars'][$var] = (double) $_POST[$var];
        }
    }
    foreach ($possible_bools as $var) {
        if (isset($_POST[$var])) {
            $regOptions['extra_register_vars'][$var] = empty($_POST[$var]) ? 0 : 1;
        }
    }
    // Registration options are always default options...
    if (isset($_POST['default_options'])) {
        $_POST['options'] = isset($_POST['options']) ? $_POST['options'] + $_POST['default_options'] : $_POST['default_options'];
    }
    $regOptions['theme_vars'] = isset($_POST['options']) && is_array($_POST['options']) ? $_POST['options'] : array();
    // Make sure they are clean, dammit!
    $regOptions['theme_vars'] = htmlspecialchars__recursive($regOptions['theme_vars']);
    // If Quick Reply hasn't been set then set it to be shown but collapsed.
    if (!isset($regOptions['theme_vars']['display_quick_reply'])) {
        $regOptions['theme_vars']['display_quick_reply'] = 1;
    }
    // Check whether we have fields that simply MUST be displayed?
    $request = smf_db_query('
		SELECT col_name, field_name, field_type, field_length, mask, show_reg
		FROM {db_prefix}custom_fields
		WHERE active = {int:is_active}', array('is_active' => 1));
    $custom_field_errors = array();
    while ($row = mysql_fetch_assoc($request)) {
        // Don't allow overriding of the theme variables.
        if (isset($regOptions['theme_vars'][$row['col_name']])) {
            unset($regOptions['theme_vars'][$row['col_name']]);
        }
        // Not actually showing it then?
        if (!$row['show_reg']) {
            continue;
        }
        // Prepare the value!
        $value = isset($_POST['customfield'][$row['col_name']]) ? trim($_POST['customfield'][$row['col_name']]) : '';
        // We only care for text fields as the others are valid to be empty.
        if (!in_array($row['field_type'], array('check', 'select', 'radio'))) {
            // Is it too long?
            if ($row['field_length'] && $row['field_length'] < commonAPI::strlen($value)) {
                $custom_field_errors[] = array('custom_field_too_long', array($row['field_name'], $row['field_length']));
            }
            // Any masks to apply?
            if ($row['field_type'] == 'text' && !empty($row['mask']) && $row['mask'] != 'none') {
                //!!! We never error on this - just ignore it at the moment...
                if ($row['mask'] == 'email' && (preg_match('~^[0-9A-Za-z=_+\\-/][0-9A-Za-z=_\'+\\-/\\.]*@[\\w\\-]+(\\.[\\w\\-]+)*(\\.[\\w]{2,6})$~', $value) === 0 || strlen($value) > 255)) {
                    $custom_field_errors[] = array('custom_field_invalid_email', array($row['field_name']));
                } elseif ($row['mask'] == 'number' && preg_match('~[^\\d]~', $value)) {
                    $custom_field_errors[] = array('custom_field_not_number', array($row['field_name']));
                } elseif (substr($row['mask'], 0, 5) == 'regex' && preg_match(substr($row['mask'], 5), $value) === 0) {
                    $custom_field_errors[] = array('custom_field_inproper_format', array($row['field_name']));
                }
            }
        }
        // Is this required but not there?
        if (trim($value) == '' && $row['show_reg'] > 1) {
            $custom_field_errors[] = array('custom_field_empty', array($row['field_name']));
        }
    }
    mysql_free_result($request);
    // Process any errors.
    if (!empty($custom_field_errors)) {
        loadLanguage('Errors');
        foreach ($custom_field_errors as $error) {
            $reg_errors[] = vsprintf($txt['error_' . $error[0]], $error[1]);
        }
    }
    // Lets check for other errors before trying to register the member.
    if (!empty($reg_errors)) {
        $_REQUEST['step'] = 2;
        return Register($reg_errors);
    }
    // If they're wanting to use OpenID we need to validate them first.
    if (empty($_SESSION['openid']['verified']) && !empty($_POST['authenticate']) && $_POST['authenticate'] == 'openid') {
        // What do we need to save?
        $save_variables = array();
        foreach ($_POST as $k => $v) {
            if (!in_array($k, array('sc', 'sesc', $context['session_var'], 'passwrd1', 'passwrd2', 'regSubmit'))) {
                $save_variables[$k] = $v;
            }
        }
        require_once $sourcedir . '/lib/Subs-OpenID.php';
        smf_openID_validate($_POST['openid_identifier'], false, $save_variables);
    } elseif ($verifiedOpenID || !empty($_POST['openid_identifier']) && $_POST['authenticate'] == 'openid') {
        $regOptions['username'] = !empty($_POST['user']) && trim($_POST['user']) != '' ? $_POST['user'] : $_SESSION['openid']['nickname'];
        $regOptions['email'] = !empty($_POST['email']) && trim($_POST['email']) != '' ? $_POST['email'] : $_SESSION['openid']['email'];
        $regOptions['auth_method'] = 'openid';
        $regOptions['openid'] = !empty($_POST['openid_identifier']) ? $_POST['openid_identifier'] : $_SESSION['openid']['openid_uri'];
    }
    $memberID = registerMember($regOptions, true);
    // What there actually an error of some kind dear boy?
    if (is_array($memberID)) {
        $reg_errors = array_merge($reg_errors, $memberID);
        $_REQUEST['step'] = 2;
        return Register($reg_errors);
    }
    // Do our spam protection now.
    spamProtection('register');
    HookAPI::callHook('register_process');
    // We'll do custom fields after as then we get to use the helper function!
    if (!empty($_POST['customfield'])) {
        require_once $sourcedir . '/Profile.php';
        require_once $sourcedir . '/Profile-Modify.php';
        makeCustomFieldChanges($memberID, 'register');
    }
    // If COPPA has been selected then things get complicated, setup the template.
    if (!empty($modSettings['coppaAge']) && empty($_SESSION['skip_coppa'])) {
        redirectexit('action=coppa;member=' . $memberID);
    } elseif (!empty($modSettings['registration_method'])) {
        EoS_Smarty::loadTemplate('register/base');
        EoS_Smarty::getConfigInstance()->registerHookTemplate('register_content_area', 'register/done');
        $context += array('page_title' => $txt['register'], 'title' => $txt['registration_successful'], 'description' => $modSettings['registration_method'] == 2 ? $txt['approval_after_registration'] : $txt['activate_after_registration']);
    } else {
        HookAPI::callHook('integrate_activate', array($row['member_name']));
        setLoginCookie(60 * $modSettings['cookieTime'], $memberID, sha1(sha1(strtolower($regOptions['username']) . $regOptions['password']) . $regOptions['register_vars']['password_salt']));
        redirectexit('action=login2;sa=check;member=' . $memberID, $context['server']['needs_login_fix']);
    }
}