/**
* Prints a setting row for use in options.php?do=options
*
* @param	array	Settings array
* @param	array	Phrases
*/
function print_setting_row($setting, $settingphrase)
{
    global $vbulletin, $vbphrase, $bgcounter, $settingphrase, $stylevar;
    $settingid = $setting['varname'];
    echo '<tbody>';
    print_description_row(iif($vbulletin->debug, '<div class="smallfont" style="float:' . $stylevar['right'] . '">' . construct_link_code($vbphrase['edit'], "options.php?" . $vbulletin->session->vars['sessionurl'] . "do=editsetting&amp;varname={$setting['varname']}") . construct_link_code($vbphrase['delete'], "options.php?" . $vbulletin->session->vars['sessionurl'] . "do=removesetting&amp;varname={$setting['varname']}") . '</div>') . '<div>' . $settingphrase["setting_{$setting['varname']}_title"] . "<a name=\"{$setting['varname']}\"></a></div>", 0, 2, 'optiontitle' . ($vbulletin->debug ? "\" title=\"\$vbulletin->options['" . $setting['varname'] . "']" : ''));
    echo "</tbody><tbody id=\"tbody_{$settingid}\">\r\n";
    // make sure all rows use the alt1 class
    $bgcounter--;
    $description = "<div class=\"smallfont\"" . ($vbulletin->debug ? "title=\"\$vbulletin->options['{$setting['varname']}']\"" : '') . ">" . $settingphrase["setting_{$setting['varname']}_desc"] . '</div>';
    $name = "setting[{$setting['varname']}]";
    $right = "<span class=\"smallfont\">{$vbphrase['error']}</span>";
    $width = 40;
    $rows = 8;
    if (preg_match('#^input:?(\\d+)$#s', $setting['optioncode'], $matches)) {
        $width = $matches[1];
        $setting['optioncode'] = '';
    } else {
        if (preg_match('#^textarea:?(\\d+)(,(\\d+))?$#s', $setting['optioncode'], $matches)) {
            $rows = $matches[1];
            if ($matches[2]) {
                $width = $matches[3];
            }
            $setting['optioncode'] = 'textarea';
        } else {
            if (preg_match('#^bitfield:(.*)$#siU', $setting['optioncode'], $matches)) {
                $setting['optioncode'] = 'bitfield';
                $setting['bitfield'] =& fetch_bitfield_definitions($matches[1]);
            } else {
                if (preg_match('#^(select|radio):(piped|eval)(\\r\\n|\\n|\\r)(.*)$#siU', $setting['optioncode'], $matches)) {
                    $setting['optioncode'] = "{$matches['1']}:{$matches['2']}";
                    $setting['optiondata'] = trim($matches[4]);
                } else {
                    if (preg_match('#^usergroup:?(\\d+)$#s', $setting['optioncode'], $matches)) {
                        $size = intval($matches[1]);
                        $setting['optioncode'] = 'usergroup';
                    } else {
                        if (preg_match('#^(usergroupextra)(\\r\\n|\\n|\\r)(.*)$#siU', $setting['optioncode'], $matches)) {
                            $setting['optioncode'] = 'usergroupextra';
                            $setting['optiondata'] = trim($matches[3]);
                        }
                    }
                }
            }
        }
    }
    switch ($setting['optioncode']) {
        // input type="text"
        case '':
            print_input_row($description, $name, $setting['value'], 1, $width);
            break;
            // input type="radio"
        // input type="radio"
        case 'yesno':
            print_yes_no_row($description, $name, $setting['value']);
            break;
            // textarea
        // textarea
        case 'textarea':
            print_textarea_row($description, $name, $setting['value'], $rows, "{$width}\" style=\"width:90%");
            break;
            // bitfield
        // bitfield
        case 'bitfield':
            $setting['value'] = intval($setting['value']);
            $setting['html'] = '';
            if ($setting['bitfield'] === NULL) {
                print_label_row($description, construct_phrase("<strong>{$vbphrase['settings_bitfield_error']}</strong>", implode(',', vB_Bitfield_Builder::fetch_errors())), '', 'top', $name, 40);
            } else {
                #$setting['html'] .= "<fieldset><legend>$vbphrase[yes] / $vbphrase[no]</legend>";
                $setting['html'] .= "<div id=\"ctrl_setting[{$setting['varname']}]\" class=\"smallfont\">\r\n";
                $setting['html'] .= "<input type=\"hidden\" name=\"setting[{$setting['varname']}][0]\" value=\"0\" />\r\n";
                foreach ($setting['bitfield'] as $key => $value) {
                    $value = intval($value);
                    $setting['html'] .= "<table style=\"width:175px; float:{$stylevar['left']}\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr valign=\"top\">\n\t\t\t\t\t<td><input type=\"checkbox\" name=\"setting[{$setting['varname']}][{$value}]\" id=\"setting[{$setting['varname']}]_{$key}\" value=\"{$value}\"" . ($setting['value'] & $value ? ' checked="checked"' : '') . " /></td>\n\t\t\t\t\t<td width=\"100%\" style=\"padding-top:4px\"><label for=\"setting[{$setting['varname']}]_{$key}\" class=\"smallfont\">" . fetch_phrase_from_key($key) . "</label></td>\r\n</tr></table>\r\n";
                }
                $setting['html'] .= "</div>\r\n";
                #$setting['html'] .= "</fieldset>";
                print_label_row($description, $setting['html'], '', 'top', $name, 40);
            }
            break;
            // select:piped
        // select:piped
        case 'select:piped':
            print_select_row($description, $name, fetch_piped_options($setting['optiondata']), $setting['value']);
            break;
            // radio:piped
        // radio:piped
        case 'radio:piped':
            print_radio_row($description, $name, fetch_piped_options($setting['optiondata']), $setting['value'], 'smallfont');
            break;
            // select:eval
        // select:eval
        case 'select:eval':
            $options = null;
            eval($setting['optiondata']);
            if (is_array($options) and !empty($options)) {
                print_select_row($description, $name, $options, $setting['value']);
            } else {
                print_input_row($description, $name, $setting['value']);
            }
            break;
            // radio:eval
        // radio:eval
        case 'radio:eval':
            $options = null;
            eval($setting['optiondata']);
            if (is_array($options) and !empty($options)) {
                print_radio_row($description, $name, $options, $setting['value'], 'smallfont');
            } else {
                print_input_row($description, $name, $setting['value']);
            }
            break;
        case 'username':
            if (intval($setting['value']) and $userinfo = $vbulletin->db->query_first("SELECT username FROM " . TABLE_PREFIX . "user WHERE userid = " . intval($setting['value']))) {
                print_input_row($description, $name, $userinfo['username'], false);
            } else {
                print_input_row($description, $name);
            }
            break;
        case 'usergroup':
            $usergrouplist = array();
            foreach ($vbulletin->usergroupcache as $usergroup) {
                $usergrouplist["{$usergroup['usergroupid']}"] = $usergroup['title'];
            }
            if ($size > 1) {
                print_select_row($description, $name . '[]', array(0 => '') + $usergrouplist, unserialize($setting['value']), false, $size, true);
            } else {
                print_select_row($description, $name, $usergrouplist, $setting['value']);
            }
            break;
        case 'usergroupextra':
            $usergrouplist = fetch_piped_options($setting['optiondata']);
            foreach ($vbulletin->usergroupcache as $usergroup) {
                $usergrouplist["{$usergroup['usergroupid']}"] = $usergroup['title'];
            }
            print_select_row($description, $name, $usergrouplist, $setting['value']);
            break;
            // arbitrary number of <input type="text" />
        // arbitrary number of <input type="text" />
        case 'multiinput':
            $setting['html'] = "<div id=\"ctrl_{$setting['varname']}\"><fieldset id=\"multi_input_fieldset_{$setting['varname']}\" style=\"padding:4px\">";
            $setting['values'] = unserialize($setting['value']);
            $setting['values'] = is_array($setting['values']) ? $setting['values'] : array();
            $setting['values'][] = '';
            foreach ($setting['values'] as $key => $value) {
                $setting['html'] .= "<div id=\"multi_input_container_{$setting['varname']}_{$key}\">" . ($key + 1) . " <input type=\"text\" class=\"bginput\" name=\"setting[{$setting['varname']}][{$key}]\" id=\"multi_input_{$setting['varname']}_{$key}\" size=\"40\" value=\"" . htmlspecialchars_uni($value) . "\" tabindex=\"1\" /></div>";
            }
            $i = sizeof($setting['values']);
            if ($i == 0) {
                $setting['html'] .= "<div><input type=\"text\" class=\"bginput\" name=\"setting[{$setting['varname']}][{$i}]\" size=\"40\" tabindex=\"1\" /></div>";
            }
            $setting['html'] .= "\n\t\t\t\t</fieldset>\n\t\t\t\t<div class=\"smallfont\"><a href=\"#\" onclick=\"return multi_input['{$setting['varname']}'].add()\">Add Another Option</a></div>\n\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\t<!--\n\t\t\t\tmulti_input['{$setting['varname']}'] = new vB_Multi_Input('{$setting['varname']}', {$i}, '" . $vbulletin->options['cpstylefolder'] . "');\n\t\t\t\t//-->\n\t\t\t\t</script>\n\t\t\t";
            print_label_row($description, $setting['html']);
            break;
            // default registration options
        // default registration options
        case 'defaultregoptions':
            $setting['value'] = intval($setting['value']);
            $checkbox_options = array('receiveemail' => 'display_email', 'adminemail' => 'receive_admin_emails', 'invisiblemode' => 'invisible_mode', 'vcard' => 'allow_vcard_download', 'signature' => 'display_signatures', 'avatar' => 'display_avatars', 'image' => 'display_images', 'showreputation' => 'display_reputation', 'enablepm' => 'receive_private_messages', 'emailonpm' => 'send_notification_email_when_a_private_message_is_received', 'pmpopup' => 'pop_up_notification_box_when_a_private_message_is_received');
            $setting['value'] = intval($setting['value']);
            $setting['html'] = '';
            #$setting['html'] .= "<fieldset><legend>$vbphrase[yes] / $vbphrase[no]</legend>";
            $setting['html'] .= "<div id=\"ctrl_setting[{$setting['varname']}]\" class=\"smallfont\">\r\n";
            $setting['html'] .= "<input type=\"hidden\" name=\"setting[{$setting['varname']}][0]\" value=\"0\" />\r\n";
            foreach ($checkbox_options as $key => $phrase) {
                $value = $vbulletin->bf_misc_regoptions["{$key}"];
                $setting['html'] .= "<table style=\"width:175px; float:{$stylevar['left']}\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr valign=\"top\">\n\t\t\t\t<td><input type=\"checkbox\" name=\"setting[{$setting['varname']}][{$value}]\" id=\"setting[{$setting['varname']}]_{$key}\" value=\"{$value}\"" . ($setting['value'] & $value ? ' checked="checked"' : '') . " /></td>\n\t\t\t\t<td width=\"100%\" style=\"padding-top:4px\"><label for=\"setting[{$setting['varname']}]_{$key}\" class=\"smallfont\">" . fetch_phrase_from_key($phrase) . "</label></td>\r\n</tr></table>\r\n";
            }
            #$setting['html'] .= "</fieldset>";
            print_label_row($description, $setting['html'], '', 'top', $name, 40);
            break;
            // cp folder options
        // cp folder options
        case 'cpstylefolder':
            if ($folders = fetch_cpcss_options() and !empty($folders)) {
                print_select_row($description, $name, $folders, $setting['value'], 1, 6);
            } else {
                print_input_row($description, $name, $setting['value'], 1, 40);
            }
            break;
            // cookiepath / cookiedomain options
        // cookiepath / cookiedomain options
        case 'cookiepath':
        case 'cookiedomain':
            $func = 'fetch_valid_' . $setting['optioncode'] . 's';
            $cookiesettings = $func($setting['optioncode'] == 'cookiepath' ? $vbulletin->script : $_SERVER['HTTP_HOST'], $vbphrase['blank']);
            $setting['found'] = in_array($setting['value'], array_keys($cookiesettings));
            $setting['html'] = "\n\t\t\t<div id=\"ctrl_{$setting['varname']}\">\n\t\t\t<fieldset>\n\t\t\t\t<legend>{$vbphrase['suggested_settings']}</legend>\n\t\t\t\t<div style=\"padding:4px\">\n\t\t\t\t\t<select name=\"setting[{$setting['varname']}]\" tabindex=\"1\" class=\"bginput\">" . construct_select_options($cookiesettings, $setting['value']) . "\n\t\t\t\t\t</select>\n\t\t\t\t</div>\n\t\t\t</fieldset>\n\t\t\t<br />\n\t\t\t<fieldset>\n\t\t\t\t<legend>{$vbphrase['custom_setting']}</legend>\n\t\t\t\t<div style=\"padding:4px\">\n\t\t\t\t\t<label for=\"{$settingid}o\"><input type=\"checkbox\" id=\"{$settingid}o\" name=\"setting[{$settingid}_other]\" tabindex=\"1\" value=\"1\"" . ($setting['found'] ? '' : ' checked="checked"') . " />{$vbphrase['use_custom_setting']}\n\t\t\t\t\t</label><br />\n\t\t\t\t\t<input type=\"text\" class=\"bginput\" size=\"25\" name=\"setting[{$settingid}_value]\" value=\"" . ($setting['found'] ? '' : $setting['value']) . "\" />\n\t\t\t\t</div>\n\t\t\t</fieldset>\n\t\t\t</div>";
            print_label_row($description, $setting['html'], '', 'top', $name, 50);
            break;
            // just a label
        // just a label
        default:
            $handled = false;
            ($hook = vBulletinHook::fetch_hook('admin_options_print')) ? eval($hook) : false;
            if (!$handled) {
                eval("\$right = \"<div id=\\\"ctrl_setting[{$setting['varname']}]\\\">{$setting['optioncode']}</div>\";");
                print_label_row($description, $right, '', 'top', $name, 50);
            }
            break;
    }
    echo "</tbody>\r\n";
    $valid = exec_setting_validation_code($setting['varname'], $setting['value'], $setting['validationcode']);
    echo "<tbody id=\"tbody_error_{$settingid}\" style=\"display:" . (($valid === 1 or $valid === true) ? 'none' : '') . "\"><tr><td class=\"alt1 smallfont\" colspan=\"2\"><div style=\"padding:4px; border:solid 1px red; background-color:white; color:black\"><strong>{$vbphrase['error']}</strong>:<div id=\"span_error_{$settingid}\">{$valid}</div></div></td></tr></tbody>";
}
Beispiel #2
0
    file_download($doc, 'vbulletin-settings.xml', 'text/xml');
}
// #############################################################################
// ajax setting value validation
if ($_POST['do'] == 'validate') {
    $vbulletin->input->clean_array_gpc('p', array('varname' => TYPE_STR, 'setting' => TYPE_ARRAY));
    $varname = convert_urlencoded_unicode($vbulletin->GPC['varname']);
    $value = convert_urlencoded_unicode($vbulletin->GPC['setting']["{$varname}"]);
    require_once DIR . '/includes/class_xml.php';
    $xml = new vB_AJAX_XML_Builder($vbulletin, 'text/xml');
    $xml->add_group('setting');
    $xml->add_tag('varname', $varname);
    if ($setting = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "setting WHERE varname = '" . $db->escape_string($varname) . "'")) {
        $raw_value = $value;
        $value = validate_setting_value($value, $setting['datatype']);
        $valid = exec_setting_validation_code($setting['varname'], $value, $setting['validationcode'], $raw_value);
    } else {
        $valid = 1;
    }
    $xml->add_tag('valid', $valid);
    $xml->close_group();
    $xml->print_xml();
}
// ***********************************************************************
print_cp_header($vbphrase['vbulletin_options']);
// ###################### Start do import settings XML #######################
if ($_POST['do'] == 'doimport') {
    $vbulletin->input->clean_array_gpc('p', array('serverfile' => TYPE_STR, 'restore' => TYPE_BOOL, 'blacklist' => TYPE_BOOL));
    $vbulletin->input->clean_array_gpc('f', array('settingsfile' => TYPE_FILE));
    if (is_demo_mode()) {
        print_cp_message('This function is disabled within demo mode');
/**
* Prints a setting row for use in options.php?do=options
*
* @param	array	Settings array
* @param	array	Phrases
*/
function print_setting_row($setting, $settingphrase, $option_config = true, $userContext = false)
{
    global $vbulletin, $bgcounter, $vbphrase;
    $settingid = $setting['varname'];
    if (empty($userContext)) {
        $userContext = vB::getUserContext();
    }
    echo '<tbody>';
    $vb5_config = vB::getConfig();
    print_description_row(iif($vb5_config['Misc']['debug'] and $option_config and $userContext->hasAdminPermission('canadminsettingsall'), '<div class="smallfont" style="float:' . vB_Template_Runtime::fetchStyleVar('right') . '">' . construct_link_code($vbphrase['edit'], "options.php?" . vB::getCurrentSession()->get('sessionurl') . "do=editsetting&amp;varname={$setting['varname']}") . construct_link_code($vbphrase['delete'], "options.php?" . vB::getCurrentSession()->get('sessionurl') . "do=removesetting&amp;varname={$setting['varname']}") . '</div>') . '<div>' . $settingphrase["setting_{$setting['varname']}_title"] . "<a name=\"{$setting['varname']}\"></a></div>", 0, 2, 'optiontitle' . ($vb5_config['Misc']['debug'] ? "\" title=\"\$vbulletin->options['" . $setting['varname'] . "']" : ''));
    echo "</tbody><tbody id=\"tbody_{$settingid}\">\r\n";
    // make sure all rows use the alt1 class
    $bgcounter--;
    $description = "<div class=\"smallfont\"" . ($vb5_config['Misc']['debug'] ? " title=\"\$vbulletin->options['{$setting['varname']}']\"" : '') . ">" . $settingphrase["setting_{$setting['varname']}_desc"] . '</div>';
    $name = "setting[{$setting['varname']}]";
    $right = "<span class=\"smallfont\">{$vbphrase['error']}</span>";
    $width = 40;
    $rows = 8;
    if (preg_match('#^input:?(\\d+)$#s', $setting['optioncode'], $matches)) {
        $width = $matches[1];
        $setting['optioncode'] = '';
    } else {
        if (preg_match('#^textarea:?(\\d+)(,(\\d+))?$#s', $setting['optioncode'], $matches)) {
            $rows = $matches[1];
            if ($matches[2]) {
                $width = $matches[3];
            }
            $setting['optioncode'] = 'textarea';
        } else {
            if (preg_match('#^bitfield:(.*)$#siU', $setting['optioncode'], $matches)) {
                $setting['optioncode'] = 'bitfield';
                $setting['bitfield'] =& fetch_bitfield_definitions($matches[1]);
            } else {
                if (preg_match('#^(select|selectmulti|radio):(piped|eval)(\\r\\n|\\n|\\r)(.*)$#siU', $setting['optioncode'], $matches)) {
                    $setting['optioncode'] = "{$matches['1']}:{$matches['2']}";
                    $setting['optiondata'] = trim($matches[4]);
                } else {
                    if (preg_match('#^usergroup:?(\\d+)$#s', $setting['optioncode'], $matches)) {
                        $size = intval($matches[1]);
                        $setting['optioncode'] = 'usergroup';
                    } else {
                        if (preg_match('#^(usergroupextra)(\\r\\n|\\n|\\r)(.*)$#siU', $setting['optioncode'], $matches)) {
                            $setting['optioncode'] = 'usergroupextra';
                            $setting['optiondata'] = trim($matches[3]);
                        } else {
                            if (preg_match('#^profilefield:?([a-z0-9,;=]*)(?:\\r\\n|\\n|\\r)(.*)$#siU', $setting['optioncode'], $matches)) {
                                $setting['optioncode'] = 'profilefield';
                                $setting['optiondata'] = array('constraints' => trim($matches[1]), 'extraoptions' => trim($matches[2]));
                            }
                        }
                    }
                }
            }
        }
    }
    // Make setting's value the default value if it's null
    if ($setting['value'] === NULL) {
        $setting['value'] = $setting['defaultvalue'];
    }
    switch ($setting['optioncode']) {
        // input type="text"
        case '':
            print_input_row($description, $name, $setting['value'], 1, $width);
            break;
            // input type="radio"
        // input type="radio"
        case 'yesno':
            print_yes_no_row($description, $name, $setting['value']);
            break;
            // textarea
        // textarea
        case 'textarea':
            print_textarea_row($description, $name, $setting['value'], $rows, "{$width}\" style=\"width:90%");
            break;
            // bitfield
        // bitfield
        case 'bitfield':
            $setting['value'] = intval($setting['value']);
            $setting['html'] = '';
            if ($setting['bitfield'] === NULL) {
                print_label_row($description, construct_phrase("<strong>{$vbphrase['settings_bitfield_error']}</strong>", implode(',', vB_Bitfield_Builder::fetch_errors())), '', 'top', $name, 40);
            } else {
                #$setting['html'] .= "<fieldset><legend>$vbphrase[yes] / $vbphrase[no]</legend>";
                $setting['html'] .= "<div id=\"ctrl_setting[{$setting['varname']}]\" class=\"smallfont\">\r\n";
                $setting['html'] .= "<input type=\"hidden\" name=\"setting[{$setting['varname']}][0]\" value=\"0\" />\r\n";
                foreach ($setting['bitfield'] as $key => $value) {
                    $value = intval($value);
                    $setting['html'] .= "<table style=\"width:175px; float:" . vB_Template_Runtime::fetchStyleVar('left') . "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr valign=\"top\">\n\t\t\t\t\t<td><input type=\"checkbox\" name=\"setting[{$setting['varname']}][{$value}]\" id=\"setting[{$setting['varname']}]_{$key}\" value=\"{$value}\"" . ($setting['value'] & $value ? ' checked="checked"' : '') . " /></td>\n\t\t\t\t\t<td width=\"100%\" style=\"padding-top:4px\"><label for=\"setting[{$setting['varname']}]_{$key}\" class=\"smallfont\">" . fetch_phrase_from_key($key) . "</label></td>\r\n</tr></table>\r\n";
                }
                $setting['html'] .= "</div>\r\n";
                #$setting['html'] .= "</fieldset>";
                print_label_row($description, $setting['html'], '', 'top', $name, 40);
            }
            break;
            // select:piped
        // select:piped
        case 'select:piped':
            print_select_row($description, $name, fetch_piped_options($setting['optiondata']), $setting['value']);
            break;
            // radio:piped
        // radio:piped
        case 'radio:piped':
            print_radio_row($description, $name, fetch_piped_options($setting['optiondata']), $setting['value'], 'smallfont');
            break;
            // select:eval
        // select:eval
        case 'select:eval':
            $options = null;
            eval($setting['optiondata']);
            if (is_array($options) and !empty($options)) {
                print_select_row($description, $name, $options, $setting['value'], true);
            } else {
                print_input_row($description, $name, $setting['value']);
            }
            break;
            // select:eval
        // select:eval
        case 'selectmulti:eval':
            $options = null;
            eval($setting['optiondata']);
            if (is_array($options) and !empty($options)) {
                print_select_row($description, $name . '[]', $options, $setting['value'], false, 5, true);
            } else {
                print_input_row($description, $name, $setting['value']);
            }
            break;
            // radio:eval
        // radio:eval
        case 'radio:eval':
            $options = null;
            eval($setting['optiondata']);
            if (is_array($options) and !empty($options)) {
                print_radio_row($description, $name, $options, $setting['value'], 'smallfont');
            } else {
                print_input_row($description, $name, $setting['value']);
            }
            break;
        case 'username':
            $userinfo = vB::getDbAssertor()->assertQuery('user', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'userid' => $setting['value']));
            if (intval($setting['value']) and $userinfo and $userinfo->valid()) {
                $userInfo = $userinfo->current();
                print_input_row($description, $name, $userInfo['username'], false);
            } else {
                print_input_row($description, $name);
            }
            break;
        case 'usergroup':
            $usergrouplist = array();
            $usergroupcache = vB::getDatastore()->get_value('usergroupcache');
            foreach ($usergroupcache as $usergroup) {
                $usergrouplist["{$usergroup['usergroupid']}"] = $usergroup['title'];
            }
            if ($size > 1) {
                print_select_row($description, $name . '[]', array(0 => '') + $usergrouplist, unserialize($setting['value']), false, $size, true);
            } else {
                print_select_row($description, $name, $usergrouplist, $setting['value']);
            }
            break;
        case 'usergroupextra':
            $usergrouplist = fetch_piped_options($setting['optiondata']);
            $usergroupcache = vB::getDatastore()->get_value('usergroupcache');
            foreach ($usergroupcache as $usergroup) {
                $usergrouplist["{$usergroup['usergroupid']}"] = $usergroup['title'];
            }
            print_select_row($description, $name, $usergrouplist, $setting['value']);
            break;
        case 'profilefield':
            static $profilefieldlistcache = array();
            $profilefieldlisthash = md5(serialize($setting['optiondata']));
            if (!isset($profilefieldlistcache[$profilefieldlisthash])) {
                $profilefieldlist = fetch_piped_options($setting['optiondata']['extraoptions']);
                $constraints = preg_split('#;#', $setting['optiondata']['constraints'], -1, PREG_SPLIT_NO_EMPTY);
                //$where = array();
                $conditions = array();
                foreach ($constraints as $constraint) {
                    $constraint = explode('=', $constraint);
                    switch ($constraint[0]) {
                        case 'editablegt':
                            //$where[] = 'editable > ' . intval($constraint[1]);
                            $conditions[] = array('field' => 'editable', 'value' => intval($constraint[1]), 'operator' => vB_dB_Query::OPERATOR_GT);
                            break;
                        case 'types':
                            $constraint[1] = preg_split('#,#', $constraint[1], -1, PREG_SPLIT_NO_EMPTY);
                            if (!empty($constraint[1])) {
                                $conditions[] = array('field' => 'type', 'value' => $constraint[1], 'operator' => vB_dB_Query::OPERATOR_EQ);
                            }
                            break;
                    }
                }
                $profilefields = vB::getDbAssertor()->assertQuery('vBForum:profilefield', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, vB_dB_Query::CONDITIONS_KEY => $conditions), array('field' => 'displayorder', 'direction' => vB_dB_Query::SORT_ASC));
                foreach ($profilefields as $profilefield) {
                    $fieldname = "field{$profilefield['profilefieldid']}";
                    $profilefieldlist[$fieldname] = construct_phrase($vbphrase['profilefield_x_fieldid_y'], fetch_phrase_from_key("{$fieldname}_title"), $fieldname);
                }
                $profilefieldlistcache[$profilefieldlisthash] = $profilefieldlist;
                unset($profilefieldlist, $constraints, $constraint, $where, $profilefields, $profilefield, $fieldname);
            }
            print_select_row($description, $name, $profilefieldlistcache[$profilefieldlisthash], $setting['value']);
            break;
            // arbitrary number of <input type="text" />
        // arbitrary number of <input type="text" />
        case 'multiinput':
            $setting['html'] = "<div id=\"ctrl_{$setting['varname']}\"><fieldset id=\"multi_input_fieldset_{$setting['varname']}\" style=\"padding:4px\">";
            $setting['values'] = unserialize($setting['value']);
            $setting['values'] = is_array($setting['values']) ? $setting['values'] : array();
            $setting['values'][] = '';
            foreach ($setting['values'] as $key => $value) {
                $setting['html'] .= "<div id=\"multi_input_container_{$setting['varname']}_{$key}\">" . ($key + 1) . " <input type=\"text\" class=\"bginput\" name=\"setting[{$setting['varname']}][{$key}]\" id=\"multi_input_{$setting['varname']}_{$key}\" size=\"40\" value=\"" . htmlspecialchars_uni($value) . "\" tabindex=\"1\" /></div>";
            }
            $i = sizeof($setting['values']);
            if ($i == 0) {
                $setting['html'] .= "<div><input type=\"text\" class=\"bginput\" name=\"setting[{$setting['varname']}][{$i}]\" size=\"40\" tabindex=\"1\" /></div>";
            }
            $setting['html'] .= "\n\t\t\t\t</fieldset>\n\t\t\t\t<div class=\"smallfont\"><a href=\"#\" onclick=\"return multi_input['{$setting['varname']}'].add()\">Add Another Option</a></div>\n\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\t<!--\n\t\t\t\tmulti_input['{$setting['varname']}'] = new vB_Multi_Input('{$setting['varname']}', {$i}, '" . vB::getDatastore()->getOption('cpstylefolder') . "');\n\t\t\t\t//-->\n\t\t\t\t</script>\n\t\t\t";
            print_label_row($description, $setting['html']);
            break;
            // default registration options
        // default registration options
        case 'defaultregoptions':
            $setting['value'] = intval($setting['value']);
            $checkbox_options = array('receiveemail' => 'display_email_gcpuser', 'adminemail' => 'receive_admin_emails_guser', 'invisiblemode' => 'invisible_mode_guser', 'vcard' => 'allow_vcard_download_guser', 'signature' => 'display_signatures_gcpuser', 'avatar' => 'display_avatars_gcpuser', 'image' => 'display_images_gcpuser', 'showreputation' => 'display_reputation_gcpuser', 'enablepm' => 'receive_private_messages_guser', 'emailonpm' => 'send_notification_email_when_a_private_message_is_received_guser', 'pmpopup' => 'pop_up_notification_box_when_a_private_message_is_received');
            $setting['value'] = intval($setting['value']);
            $setting['html'] = '';
            #$setting['html'] .= "<fieldset><legend>$vbphrase[yes] / $vbphrase[no]</legend>";
            $setting['html'] .= "<div id=\"ctrl_setting[{$setting['varname']}]\" class=\"smallfont\">\r\n";
            $setting['html'] .= "<input type=\"hidden\" name=\"setting[{$setting['varname']}][0]\" value=\"0\" />\r\n";
            foreach ($checkbox_options as $key => $phrase) {
                $bf_misc_regoptions = vB::getDatastore()->getValue('bf_misc_regoptions');
                $value = $bf_misc_regoptions["{$key}"];
                $setting['html'] .= "<table style=\"width:175px; float:" . vB_Template_Runtime::fetchStyleVar('left') . "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr valign=\"top\">\n\t\t\t\t<td><input type=\"checkbox\" name=\"setting[{$setting['varname']}][{$value}]\" id=\"setting[{$setting['varname']}]_{$key}\" value=\"{$value}\"" . ($setting['value'] & $value ? ' checked="checked"' : '') . " /></td>\n\t\t\t\t<td width=\"100%\" style=\"padding-top:4px\"><label for=\"setting[{$setting['varname']}]_{$key}\" class=\"smallfont\">" . fetch_phrase_from_key($phrase) . "</label></td>\r\n</tr></table>\r\n";
            }
            #$setting['html'] .= "</fieldset>";
            print_label_row($description, $setting['html'], '', 'top', $name, 40);
            break;
            // cp folder options
        // cp folder options
        case 'cpstylefolder':
            if ($folders = fetch_cpcss_options() and !empty($folders)) {
                print_select_row($description, $name, $folders, $setting['value'], 1, 6);
            } else {
                print_input_row($description, $name, $setting['value'], 1, 40);
            }
            break;
            // cookiepath / cookiedomain options
        // cookiepath / cookiedomain options
        case 'cookiepath':
        case 'cookiedomain':
            $func = 'fetch_valid_' . $setting['optioncode'] . 's';
            $cookiesettings = $func($setting['optioncode'] == 'cookiepath' ? $vbulletin->script : $_SERVER['HTTP_HOST'], $vbphrase['blank']);
            $setting['found'] = in_array($setting['value'], array_keys($cookiesettings));
            $setting['html'] = "\n\t\t\t<div id=\"ctrl_{$setting['varname']}\">\n\t\t\t<fieldset>\n\t\t\t\t<legend>{$vbphrase['suggested_settings']}</legend>\n\t\t\t\t<div style=\"padding:4px\">\n\t\t\t\t\t<select name=\"setting[{$setting['varname']}]\" tabindex=\"1\" class=\"bginput\">" . construct_select_options($cookiesettings, $setting['value']) . "\n\t\t\t\t\t</select>\n\t\t\t\t</div>\n\t\t\t</fieldset>\n\t\t\t<br />\n\t\t\t<fieldset>\n\t\t\t\t<legend>{$vbphrase['custom_setting']}</legend>\n\t\t\t\t<div style=\"padding:4px\">\n\t\t\t\t\t<label for=\"{$settingid}o\"><input type=\"checkbox\" id=\"{$settingid}o\" name=\"setting[{$settingid}_other]\" tabindex=\"1\" value=\"1\"" . ($setting['found'] ? '' : ' checked="checked"') . " />{$vbphrase['use_custom_setting']}\n\t\t\t\t\t</label><br />\n\t\t\t\t\t<input type=\"text\" class=\"bginput\" size=\"25\" name=\"setting[{$settingid}_value]\" value=\"" . ($setting['found'] ? '' : $setting['value']) . "\" />\n\t\t\t\t</div>\n\t\t\t</fieldset>\n\t\t\t</div>";
            print_label_row($description, $setting['html'], '', 'top', $name, 50);
            break;
        case 'forums:all':
            $array = construct_forum_chooser_options(-1, $vbphrase['all']);
            $size = sizeof($array);
            $vbphrase['forum_is_closed_for_posting'] = $vbphrase['closed'];
            print_select_row($description, $name . '[]', $array, unserialize($setting['value']), false, $size > 10 ? 10 : $size, true);
            break;
        case 'forums:none':
            $array = construct_forum_chooser_options(0, $vbphrase['none']);
            $size = sizeof($array);
            $vbphrase['forum_is_closed_for_posting'] = $vbphrase['closed'];
            print_select_row($description, $name . '[]', $array, unserialize($setting['value']), false, $size > 10 ? 10 : $size, true);
            break;
            // just a label
        // just a label
        default:
            $handled = false;
            // Legacy Hook 'admin_options_print' Removed //
            if (!$handled) {
                eval("\$right = \"<div id=\\\"ctrl_setting[{$setting['varname']}]\\\">{$setting['optioncode']}</div>\";");
                print_label_row($description, $right, '', 'top', $name, 50);
            }
            break;
    }
    echo "</tbody>\r\n";
    $valid = exec_setting_validation_code($setting['varname'], $setting['value'], $setting['validationcode']);
    echo "<tbody id=\"tbody_error_{$settingid}\" style=\"display:" . (($valid === 1 or $valid === true) ? 'none' : '') . "\"><tr><td class=\"alt1 smallfont\" colspan=\"2\"><div style=\"padding:4px; border:solid 1px red; background-color:white; color:black\"><strong>{$vbphrase['error']}</strong>:<div id=\"span_error_{$settingid}\">{$valid}</div></div></td></tr></tbody>";
}
/**
* Prints a setting row for use in options.php?do=options
*
* @param	array	Settings array
* @param	array	Phrases
*/
function print_setting_row($setting, $settingphrase, $option_config = true)
{
    global $vbulletin, $vbphrase, $bgcounter, $settingphrase;
    $settingid = $setting['varname'];
    echo '<tbody>';
    print_description_row(iif($vbulletin->debug and $option_config, '<div class="smallfont" style="float:' . vB_Template_Runtime::fetchStyleVar('right') . '">' . construct_link_code($vbphrase['edit'], "options.php?" . $vbulletin->session->vars['sessionurl'] . "do=editsetting&amp;varname={$setting['varname']}") . construct_link_code($vbphrase['delete'], "options.php?" . $vbulletin->session->vars['sessionurl'] . "do=removesetting&amp;varname={$setting['varname']}") . '</div>') . '<div>' . $settingphrase["setting_{$setting['varname']}_title"] . "<a name=\"{$setting['varname']}\"></a></div>", 0, 2, 'optiontitle' . ($vbulletin->debug ? "\" title=\"\$vbulletin->options['" . $setting['varname'] . "']" : ''));
    echo "</tbody><tbody id=\"tbody_{$settingid}\">\r\n";
    // make sure all rows use the alt1 class
    $bgcounter--;
    $description = "<div class=\"smallfont\"" . ($vbulletin->debug ? "title=\"\$vbulletin->options['{$setting['varname']}']\"" : '') . ">" . $settingphrase["setting_{$setting['varname']}_desc"] . '</div>';
    $name = "setting[{$setting['varname']}]";
    $right = "<span class=\"smallfont\">{$vbphrase['error']}</span>";
    $width = 40;
    $rows = 8;
    if (preg_match('#^input:?(\\d+)$#s', $setting['optioncode'], $matches)) {
        $width = $matches[1];
        $setting['optioncode'] = '';
    } else {
        if (preg_match('#^textarea:?(\\d+)(,(\\d+))?$#s', $setting['optioncode'], $matches)) {
            $rows = $matches[1];
            if ($matches[2]) {
                $width = $matches[3];
            }
            $setting['optioncode'] = 'textarea';
        } else {
            if (preg_match('#^bitfield:(.*)$#siU', $setting['optioncode'], $matches)) {
                $setting['optioncode'] = 'bitfield';
                $setting['bitfield'] =& fetch_bitfield_definitions($matches[1]);
            } else {
                if (preg_match('#^(select|selectmulti|radio):(piped|eval)(\\r\\n|\\n|\\r)(.*)$#siU', $setting['optioncode'], $matches)) {
                    $setting['optioncode'] = "{$matches['1']}:{$matches['2']}";
                    $setting['optiondata'] = trim($matches[4]);
                } else {
                    if (preg_match('#^usergroup:?(\\d+)$#s', $setting['optioncode'], $matches)) {
                        $size = intval($matches[1]);
                        $setting['optioncode'] = 'usergroup';
                    } else {
                        if (preg_match('#^(usergroupextra)(\\r\\n|\\n|\\r)(.*)$#siU', $setting['optioncode'], $matches)) {
                            $setting['optioncode'] = 'usergroupextra';
                            $setting['optiondata'] = trim($matches[3]);
                        } else {
                            if (preg_match('#^profilefield:?([a-z0-9,;=]*)(?:\\r\\n|\\n|\\r)(.*)$#siU', $setting['optioncode'], $matches)) {
                                $setting['optioncode'] = 'profilefield';
                                $setting['optiondata'] = array('constraints' => trim($matches[1]), 'extraoptions' => trim($matches[2]));
                            } else {
                                if (preg_match('#^apipostidmanage(?:\\r\\n|\\n|\\r)(.*)$#siU', $setting['optioncode'], $matches)) {
                                    $setting['optioncode'] = 'apipostidmanage';
                                    $setting['optiondata'] = preg_split("#(\r\n|\n|\r)#s", $matches[1], -1, PREG_SPLIT_NO_EMPTY);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    switch ($setting['optioncode']) {
        // input type="text"
        case '':
            print_input_row($description, $name, $setting['value'], 1, $width);
            break;
            // input type="radio"
        // input type="radio"
        case 'yesno':
            print_yes_no_row($description, $name, $setting['value']);
            break;
            // textarea
        // textarea
        case 'textarea':
            print_textarea_row($description, $name, $setting['value'], $rows, "{$width}\" style=\"width:90%");
            break;
            // bitfield
        // bitfield
        case 'bitfield':
            $setting['value'] = intval($setting['value']);
            $setting['html'] = '';
            if ($setting['bitfield'] === NULL) {
                print_label_row($description, construct_phrase("<strong>{$vbphrase['settings_bitfield_error']}</strong>", implode(',', vB_Bitfield_Builder::fetch_errors())), '', 'top', $name, 40);
            } else {
                #$setting['html'] .= "<fieldset><legend>$vbphrase[yes] / $vbphrase[no]</legend>";
                $setting['html'] .= "<div id=\"ctrl_setting[{$setting['varname']}]\" class=\"smallfont\">\r\n";
                $setting['html'] .= "<input type=\"hidden\" name=\"setting[{$setting['varname']}][0]\" value=\"0\" />\r\n";
                foreach ($setting['bitfield'] as $key => $value) {
                    $value = intval($value);
                    $setting['html'] .= "<table style=\"width:175px; float:" . vB_Template_Runtime::fetchStyleVar('left') . "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr valign=\"top\">\n\t\t\t\t\t<td><input type=\"checkbox\" name=\"setting[{$setting['varname']}][{$value}]\" id=\"setting[{$setting['varname']}]_{$key}\" value=\"{$value}\"" . ($setting['value'] & $value ? ' checked="checked"' : '') . " /></td>\n\t\t\t\t\t<td width=\"100%\" style=\"padding-top:4px\"><label for=\"setting[{$setting['varname']}]_{$key}\" class=\"smallfont\">" . fetch_phrase_from_key($key) . "</label></td>\r\n</tr></table>\r\n";
                }
                $setting['html'] .= "</div>\r\n";
                #$setting['html'] .= "</fieldset>";
                print_label_row($description, $setting['html'], '', 'top', $name, 40);
            }
            break;
            // select:piped
        // select:piped
        case 'select:piped':
            print_select_row($description, $name, fetch_piped_options($setting['optiondata']), $setting['value']);
            break;
            // radio:piped
        // radio:piped
        case 'radio:piped':
            print_radio_row($description, $name, fetch_piped_options($setting['optiondata']), $setting['value'], 'smallfont');
            break;
            // select:eval
        // select:eval
        case 'select:eval':
            $options = null;
            eval($setting['optiondata']);
            if (is_array($options) and !empty($options)) {
                print_select_row($description, $name, $options, $setting['value']);
            } else {
                print_input_row($description, $name, $setting['value']);
            }
            break;
            // select:eval
        // select:eval
        case 'selectmulti:eval':
            $options = null;
            eval($setting['optiondata']);
            if (is_array($options) and !empty($options)) {
                print_select_row($description, $name . '[]', $options, $setting['value'], false, 5, true);
            } else {
                print_input_row($description, $name, $setting['value']);
            }
            break;
            // radio:eval
        // radio:eval
        case 'radio:eval':
            $options = null;
            eval($setting['optiondata']);
            if (is_array($options) and !empty($options)) {
                print_radio_row($description, $name, $options, $setting['value'], 'smallfont');
            } else {
                print_input_row($description, $name, $setting['value']);
            }
            break;
        case 'username':
            if (intval($setting['value']) and $userinfo = $vbulletin->db->query_first("SELECT username FROM " . TABLE_PREFIX . "user WHERE userid = " . intval($setting['value']))) {
                print_input_row($description, $name, $userinfo['username'], false);
            } else {
                print_input_row($description, $name);
            }
            break;
        case 'usergroup':
            $usergrouplist = array();
            foreach ($vbulletin->usergroupcache as $usergroup) {
                $usergrouplist["{$usergroup['usergroupid']}"] = $usergroup['title'];
            }
            if ($size > 1) {
                print_select_row($description, $name . '[]', array(0 => '') + $usergrouplist, unserialize($setting['value']), false, $size, true);
            } else {
                print_select_row($description, $name, $usergrouplist, $setting['value']);
            }
            break;
        case 'usergroupextra':
            $usergrouplist = fetch_piped_options($setting['optiondata']);
            foreach ($vbulletin->usergroupcache as $usergroup) {
                $usergrouplist["{$usergroup['usergroupid']}"] = $usergroup['title'];
            }
            print_select_row($description, $name, $usergrouplist, $setting['value']);
            break;
        case 'profilefield':
            static $profilefieldlistcache = array();
            $profilefieldlisthash = md5(serialize($setting['optiondata']));
            if (!isset($profilefieldlistcache[$profilefieldlisthash])) {
                $profilefieldlist = fetch_piped_options($setting['optiondata']['extraoptions']);
                $constraints = preg_split('#;#', $setting['optiondata']['constraints'], -1, PREG_SPLIT_NO_EMPTY);
                $where = array();
                foreach ($constraints as $constraint) {
                    $constraint = explode('=', $constraint);
                    switch ($constraint[0]) {
                        case 'editablegt':
                            $where[] = 'editable > ' . intval($constraint[1]);
                            break;
                        case 'types':
                            $constraint[1] = preg_split('#,#', $constraint[1], -1, PREG_SPLIT_NO_EMPTY);
                            if (!empty($constraint[1])) {
                                $where[] = "type IN('" . implode("', '", array_map(array($vbulletin->db, 'escape_string'), $constraint[1])) . "')";
                            }
                            break;
                    }
                }
                $profilefields = $vbulletin->db->query_read_slave("\n\t\t\t\t\tSELECT *\n\t\t\t\t\tFROM " . TABLE_PREFIX . "profilefield\n\t\t\t\t\t" . (!empty($where) ? 'WHERE ' . implode(' AND ', $where) : '') . "\n\t\t\t\t\tORDER BY displayorder\n\t\t\t\t");
                while ($profilefield = $vbulletin->db->fetch_array($profilefields)) {
                    $fieldname = "field{$profilefield['profilefieldid']}";
                    $profilefieldlist[$fieldname] = construct_phrase($vbphrase['profilefield_x_fieldid_y'], fetch_phrase_from_key("{$fieldname}_title"), $fieldname);
                }
                $profilefieldlistcache[$profilefieldlisthash] = $profilefieldlist;
                unset($profilefieldlist, $constraints, $constraint, $where, $profilefields, $profilefield, $fieldname);
            }
            print_select_row($description, $name, $profilefieldlistcache[$profilefieldlisthash], $setting['value']);
            break;
            // arbitrary number of <input type="text" />
        // arbitrary number of <input type="text" />
        case 'multiinput':
            $setting['html'] = "<div id=\"ctrl_{$setting['varname']}\"><fieldset id=\"multi_input_fieldset_{$setting['varname']}\" style=\"padding:4px\">";
            $setting['values'] = unserialize($setting['value']);
            $setting['values'] = is_array($setting['values']) ? $setting['values'] : array();
            $setting['values'][] = '';
            foreach ($setting['values'] as $key => $value) {
                $setting['html'] .= "<div id=\"multi_input_container_{$setting['varname']}_{$key}\">" . ($key + 1) . " <input type=\"text\" class=\"bginput\" name=\"setting[{$setting['varname']}][{$key}]\" id=\"multi_input_{$setting['varname']}_{$key}\" size=\"40\" value=\"" . htmlspecialchars_uni($value) . "\" tabindex=\"1\" /></div>";
            }
            $i = sizeof($setting['values']);
            if ($i == 0) {
                $setting['html'] .= "<div><input type=\"text\" class=\"bginput\" name=\"setting[{$setting['varname']}][{$i}]\" size=\"40\" tabindex=\"1\" /></div>";
            }
            $setting['html'] .= "\n\t\t\t\t</fieldset>\n\t\t\t\t<div class=\"smallfont\"><a href=\"#\" onclick=\"return multi_input['{$setting['varname']}'].add()\">Add Another Option</a></div>\n\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\t<!--\n\t\t\t\tmulti_input['{$setting['varname']}'] = new vB_Multi_Input('{$setting['varname']}', {$i}, '" . $vbulletin->options['cpstylefolder'] . "');\n\t\t\t\t//-->\n\t\t\t\t</script>\n\t\t\t";
            print_label_row($description, $setting['html']);
            break;
            // activity stream options
        // activity stream options
        case 'activitystream':
            $options = array();
            $activities = $vbulletin->db->query_read("\n\t\t\t\tSELECT\n\t\t\t\t\ttypeid, section, type, enabled\n\t\t\t\tFROM " . TABLE_PREFIX . "activitystreamtype AS a\n\t\t\t\tINNER JOIN " . TABLE_PREFIX . "package AS p ON (p.packageid = a.packageid)\n\t\t\t\tORDER BY section, type\n\t\t\t");
            while ($activity = $vbulletin->db->fetch_array($activities)) {
                $options["{$activity['section']}_{$activity['type']}"] = $activity;
            }
            $setting['html'] = '';
            $setting['html'] .= "<div id=\"ctrl_setting[{$setting['varname']}]\" class=\"smallfont\">\r\n";
            $setting['html'] .= "<input type=\"hidden\" name=\"setting[{$setting['varname']}][0]\" value=\"0\" />\r\n";
            foreach ($options as $key => $activity) {
                $setting['html'] .= "<table style=\"width:175px; float:" . vB_Template_Runtime::fetchStyleVar('left') . "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr valign=\"top\">\n\t\t\t\t<td><input type=\"checkbox\" name=\"setting[{$setting['varname']}][{$activity['typeid']}]\" id=\"setting[{$setting['varname']}]_{$key}\" value=\"1\"" . ($activity['enabled'] ? ' checked="checked"' : '') . " /></td>\n\t\t\t\t<td width=\"100%\" style=\"padding-top:4px\"><label for=\"setting[{$setting['varname']}]_{$key}\" class=\"smallfont\">" . fetch_phrase_from_key($key) . "</label></td>\r\n</tr></table>\r\n";
            }
            print_label_row($description, $setting['html'], '', 'top', $name, 40);
            break;
            // default registration options
        // default registration options
        case 'defaultregoptions':
            $setting['value'] = intval($setting['value']);
            $checkbox_options = array('receiveemail' => 'display_email', 'adminemail' => 'receive_admin_emails', 'invisiblemode' => 'invisible_mode', 'vcard' => 'allow_vcard_download', 'signature' => 'display_signatures', 'avatar' => 'display_avatars', 'image' => 'display_images', 'showreputation' => 'display_reputation', 'enablepm' => 'receive_private_messages', 'emailonpm' => 'send_notification_email_when_a_private_message_is_received', 'pmpopup' => 'pop_up_notification_box_when_a_private_message_is_received');
            $setting['value'] = intval($setting['value']);
            $setting['html'] = '';
            #$setting['html'] .= "<fieldset><legend>$vbphrase[yes] / $vbphrase[no]</legend>";
            $setting['html'] .= "<div id=\"ctrl_setting[{$setting['varname']}]\" class=\"smallfont\">\r\n";
            $setting['html'] .= "<input type=\"hidden\" name=\"setting[{$setting['varname']}][0]\" value=\"0\" />\r\n";
            foreach ($checkbox_options as $key => $phrase) {
                $value = $vbulletin->bf_misc_regoptions["{$key}"];
                $setting['html'] .= "<table style=\"width:175px; float:" . vB_Template_Runtime::fetchStyleVar('left') . "\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr valign=\"top\">\n\t\t\t\t<td><input type=\"checkbox\" name=\"setting[{$setting['varname']}][{$value}]\" id=\"setting[{$setting['varname']}]_{$key}\" value=\"{$value}\"" . ($setting['value'] & $value ? ' checked="checked"' : '') . " /></td>\n\t\t\t\t<td width=\"100%\" style=\"padding-top:4px\"><label for=\"setting[{$setting['varname']}]_{$key}\" class=\"smallfont\">" . fetch_phrase_from_key($phrase) . "</label></td>\r\n</tr></table>\r\n";
            }
            #$setting['html'] .= "</fieldset>";
            print_label_row($description, $setting['html'], '', 'top', $name, 40);
            break;
            // cp folder options
        // cp folder options
        case 'cpstylefolder':
            if ($folders = fetch_cpcss_options() and !empty($folders)) {
                print_select_row($description, $name, $folders, $setting['value'], 1, 6);
            } else {
                print_input_row($description, $name, $setting['value'], 1, 40);
            }
            break;
        case 'apipostidmanage':
            $setting['html'] = "<div id=\"ctrl_apipostidmanage\"><fieldset id=\"multi_input_fieldset_apipostidmanage}\" style=\"padding:4px\">";
            $setting['values'] = unserialize($setting['value']);
            $setting['values'] = is_array($setting['values']) ? $setting['values'] : array();
            $setting['html'] .= "\n\t\t\t\t<div style=\"padding:4px\">\n\t\t\t\t\t<span style=\"display:block\">{$vbphrase['apipostidmanage_enable']}</span>\n\t\t\t\t\t<label for=\"multi_input_apipostidmanage_enable1\" />\n\t\t\t\t\t\t<input type=\"radio\"" . ($setting['values']['enable'] ? ' checked="checked" ' : '') . "class=\"bginput\" name=\"setting[apipostidmanage][enable]\" id=\"multi_input_apipostidmanage_enable1\"  value=\"1\" tabindex=\"1\" />\n\t\t\t\t\t\t{$vbphrase['yes']}\n\t\t\t\t\t</label>\n\t\t\t\t\t<label for=\"multi_input_{$setting['varname']}_enable2\" />\n\t\t\t\t\t\t<input type=\"radio\"" . (!$setting['values']['enable'] ? ' checked="checked" ' : '') . "class=\"bginput\" name=\"setting[apipostidmanage][enable]\" id=\"multi_input_apipostidmanage_enable2\"  value=\"0\" tabindex=\"1\" />\n\t\t\t\t\t\t{$vbphrase['no']}\n\t\t\t\t\t</label>\n\t\t\t\t</div>";
            foreach ($setting['optiondata'] as $device) {
                if (!$vbphrase['apipostidmanage_' . $device]) {
                    continue;
                }
                $setting['html'] .= "<div style=\"padding:4px\">\n\t\t\t\t\t<span style=\"display:block\">" . $vbphrase['apipostidmanage_' . $device] . "</span>\n\t\t\t\t\t<input type=\"text\" class=\"bginput\" name=\"setting[apipostidmanage][{$device}]\" id=\"multi_input_apipostidmanage_{$device}\" size=\"50\" value=\"" . htmlspecialchars_uni($setting['values'][$device]) . "\" tabindex=\"1\" />\n\t\t\t\t</div>";
            }
            $setting['html'] .= "</fieldset></div>";
            print_label_row($description, $setting['html'], '', 'top', 'apipostidmanage');
            break;
            break;
            // cookiepath / cookiedomain options
        // cookiepath / cookiedomain options
        case 'cookiepath':
        case 'cookiedomain':
            $func = 'fetch_valid_' . $setting['optioncode'] . 's';
            $cookiesettings = $func($setting['optioncode'] == 'cookiepath' ? $vbulletin->script : $_SERVER['HTTP_HOST'], $vbphrase['blank']);
            $setting['found'] = in_array($setting['value'], array_keys($cookiesettings));
            $setting['html'] = "\n\t\t\t<div id=\"ctrl_{$setting['varname']}\">\n\t\t\t<fieldset>\n\t\t\t\t<legend>{$vbphrase['suggested_settings']}</legend>\n\t\t\t\t<div style=\"padding:4px\">\n\t\t\t\t\t<select name=\"setting[{$setting['varname']}]\" tabindex=\"1\" class=\"bginput\">" . construct_select_options($cookiesettings, $setting['value']) . "\n\t\t\t\t\t</select>\n\t\t\t\t</div>\n\t\t\t</fieldset>\n\t\t\t<br />\n\t\t\t<fieldset>\n\t\t\t\t<legend>{$vbphrase['custom_setting']}</legend>\n\t\t\t\t<div style=\"padding:4px\">\n\t\t\t\t\t<label for=\"{$settingid}o\"><input type=\"checkbox\" id=\"{$settingid}o\" name=\"setting[{$settingid}_other]\" tabindex=\"1\" value=\"1\"" . ($setting['found'] ? '' : ' checked="checked"') . " />{$vbphrase['use_custom_setting']}\n\t\t\t\t\t</label><br />\n\t\t\t\t\t<input type=\"text\" class=\"bginput\" size=\"25\" name=\"setting[{$settingid}_value]\" value=\"" . ($setting['found'] ? '' : $setting['value']) . "\" />\n\t\t\t\t</div>\n\t\t\t</fieldset>\n\t\t\t</div>";
            print_label_row($description, $setting['html'], '', 'top', $name, 50);
            break;
        case 'facebooksslcheck':
            require_once DIR . '/includes/class_vurl.php';
            $vurl = new vB_vURL($vbulletin);
            $result = $vurl->test_ssl();
            print_label_row($description, $result ? $vbphrase['supported'] : $vbphrase['not_supported']);
            break;
        case 'usergroups:none':
            $array = build_usergroup_list($vbphrase['none'], 0);
            $size = sizeof($array);
            print_select_row($description, $name . '[]', $array, unserialize($setting['value']), false, $size > 10 ? 10 : $size, true);
            break;
        case 'usergroups:all':
            $array = build_usergroup_list($vbphrase['all'], -1);
            $size = sizeof($array);
            print_select_row($description, $name . '[]', $array, unserialize($setting['value']), false, $size > 10 ? 10 : $size, true);
            break;
        case 'forums:all':
            $array = construct_forum_chooser_options(-1, $vbphrase['all']);
            $size = sizeof($array);
            $vbphrase[forum_is_closed_for_posting] = $vbphrase[closed];
            print_select_row($description, $name . '[]', $array, unserialize($setting['value']), false, $size > 10 ? 10 : $size, true);
            break;
        case 'forums:none':
            $array = construct_forum_chooser_options(0, $vbphrase['none']);
            $size = sizeof($array);
            $vbphrase[forum_is_closed_for_posting] = $vbphrase[closed];
            print_select_row($description, $name . '[]', $array, unserialize($setting['value']), false, $size > 10 ? 10 : $size, true);
            break;
            // just a label
        // just a label
        default:
            $handled = false;
            ($hook = vBulletinHook::fetch_hook('admin_options_print')) ? eval($hook) : false;
            if (!$handled) {
                eval("\$right = \"<div id=\\\"ctrl_setting[{$setting['varname']}]\\\">{$setting['optioncode']}</div>\";");
                print_label_row($description, $right, '', 'top', $name, 50);
            }
            break;
    }
    echo "</tbody>\r\n";
    $valid = exec_setting_validation_code($setting['varname'], $setting['value'], $setting['validationcode']);
    echo "<tbody id=\"tbody_error_{$settingid}\" style=\"display:" . (($valid === 1 or $valid === true) ? 'none' : '') . "\"><tr><td class=\"alt1 smallfont\" colspan=\"2\"><div style=\"padding:4px; border:solid 1px red; background-color:white; color:black\"><strong>{$vbphrase['error']}</strong>:<div id=\"span_error_{$settingid}\">{$valid}</div></div></td></tr></tbody>";
}
Beispiel #5
0
 /**
  * This function changes the search type for settings
  * @param string $varname
  * @param array $setting
  * @return array, response
  */
 public function validateSettings($varname, $setting)
 {
     $this->checkHasAdminPermission('canadminsettings');
     require_once DIR . '/includes/class_xml.php';
     require_once DIR . '/includes/functions_file.php';
     require_once DIR . '/includes/adminfunctions_options.php';
     $response = array();
     $varname = convert_urlencoded_unicode($varname);
     $value = convert_urlencoded_unicode($setting["{$varname}"]);
     require_once DIR . '/includes/class_xml.php';
     $xml = new vB_XML_Builder_Ajax('text/xml');
     $xml->add_group('setting');
     $xml->add_tag('varname', $varname);
     $setting = vB::getDbAssertor()->getRow('setting', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT, 'varname' => $varname));
     if ($setting) {
         $raw_value = $value;
         $value = validate_setting_value($value, $setting['datatype']);
         $valid = exec_setting_validation_code($setting['varname'], $value, $setting['validationcode'], $raw_value);
     } else {
         $valid = 1;
     }
     $xml->add_tag('valid', $valid);
     $xml->close_group();
     $response['xml'] = $xml;
     $response['validate'] = true;
     return $response;
 }