define('CP_REDIRECT', "adminpermissions.php?" . $vbulletin->session->vars['sessionurl'] . "#user{$user['userid']}"); print_stop_message('saved_administrator_permissions_successfully'); } // ############################################################################# if ($_REQUEST['do'] == 'edit') { echo "<p align=\"center\">{$vbphrase['give_admin_access_arbitrary_html']}</p>"; print_form_header('adminpermissions', 'update'); construct_hidden_code('userid', $vbulletin->GPC['userid']); construct_hidden_code('oldpermissions', $user['adminpermissions']); print_table_header(construct_phrase($vbphrase['x_y_id_z'], $vbphrase['administrator_permissions'], $user['username'], $user['userid'])); print_label_row("{$vbphrase['administrator']}: <a href=\"user.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&u=" . $vbulletin->GPC['userid'] . "\">{$user['username']}</a>", '<div align="' . $stylevar['right'] . '"><input type="button" class="button" value=" ' . $vbphrase['all_yes'] . ' " onclick="js_check_all_option(this.form, 1);" /> <input type="button" class="button" value=" ' . $vbphrase['all_no'] . ' " onclick="js_check_all_option(this.form, 0);" /></div>', 'thead'); foreach (convert_bits_to_array($user['adminpermissions'], $ADMINPERMISSIONS) as $field => $value) { print_yes_no_row($permsphrase["{$field}"] == '' ? $vbphrase['n_a'] : $permsphrase["{$field}"], "adminpermissions[{$field}]", $value); } ($hook = vBulletinHook::fetch_hook('admin_permissions_form')) ? eval($hook) : false; print_select_row($vbphrase['control_panel_style_choice'], 'cssprefs', array_merge(array('' => "({$vbphrase['default']})"), fetch_cpcss_options()), $user['cssprefs']); print_input_row($vbphrase['dismissed_news_item_ids'], 'dismissednews', $user['dismissednews']); print_submit_row(); } // ############################################################################# if ($_REQUEST['do'] == 'modify') { print_form_header('adminpermissions', 'edit'); print_table_header($vbphrase['administrator_permissions'], 3); $users = $db->query_read("\n\t\tSELECT user.username, usergroupid, membergroupids, infractiongroupids, administrator.*\n\t\tFROM " . TABLE_PREFIX . "administrator AS administrator\n\t\tINNER JOIN " . TABLE_PREFIX . "user AS user USING(userid)\n\t\tORDER BY user.username\n\t"); while ($user = $db->fetch_array($users)) { $perms = fetch_permissions(0, $user['userid'], $user); if ($perms['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']) { print_cells_row(array("<a href=\"user.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&u={$user['userid']}\" name=\"user{$user['userid']}\"><b>{$user['username']}</b></a>", '-', construct_link_code($vbphrase['view_control_panel_log'], "adminlog.php?" . $vbulletin->session->vars['sessionurl'] . "do=view&script=&u={$user['userid']}") . construct_link_code($vbphrase['edit_permissions'], "adminpermissions.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&u={$user['userid']}")), 0, '', 0); } } print_table_footer();
/** * Displays the login form for the various control panel areas * * The actual form displayed is dependent upon the VB_AREA constant */ function print_cp_login($mismatch = false) { global $vbulletin, $vbphrase, $stylevar; $focusfield = iif($vbulletin->userinfo['userid'] == 0, 'username', 'password'); $vbulletin->input->clean_array_gpc('r', array('vb_login_username' => TYPE_NOHTML)); $printusername = iif(!empty($vbulletin->GPC['vb_login_username']), $vbulletin->GPC['vb_login_username'], $vbulletin->userinfo['username']); $vbulletin->userinfo['badlocation'] = 1; switch (VB_AREA) { case 'AdminCP': $pagetitle = $vbphrase['admin_control_panel']; $getcssoptions = fetch_cpcss_options(); $cssoptions = array(); foreach ($getcssoptions as $folder => $foldername) { $key = iif($folder == $vbulletin->options['cpstylefolder'], '', $folder); $cssoptions["{$key}"] = $foldername; } $showoptions = true; $logintype = 'cplogin'; break; case 'ModCP': $pagetitle = $vbphrase['moderator_control_panel']; $showoptions = false; $logintype = 'modcplogin'; break; default: ($hook = vBulletinHook::fetch_hook('admin_login_area_switch')) ? eval($hook) : false; } define('NO_PAGE_TITLE', true); print_cp_header($vbphrase['log_in'], "document.forms.loginform.vb_login_{$focusfield}.focus()"); require_once DIR . '/includes/functions_misc.php'; $postvars = construct_post_vars_html(); ?> <script type="text/javascript" src="../clientscript/vbulletin_md5.js"></script> <script type="text/javascript"> <!-- function js_show_options(objectid, clickedelm) { fetch_object(objectid).style.display = ""; clickedelm.disabled = true; } function js_fetch_url_append(origbit,addbit) { if (origbit.search(/\?/) != -1) { return origbit + '&' + addbit; } else { return origbit + '?' + addbit; } } function js_do_options(formobj) { if (typeof(formobj.nojs) != "undefined" && formobj.nojs.checked == true) { formobj.url.value = js_fetch_url_append(formobj.url.value, 'nojs=1'); } return true; } //--> </script> <form action="../login.php?do=login" method="post" name="loginform" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf); js_do_options(this)"> <input type="hidden" name="url" value="<?php echo $vbulletin->scriptpath; ?> " /> <input type="hidden" name="s" value="<?php echo $vbulletin->session->vars['dbsessionhash']; ?> " /> <input type="hidden" name="securitytoken" value="<?php echo $vbulletin->userinfo['securitytoken']; ?> " /> <input type="hidden" name="logintype" value="<?php echo $logintype; ?> " /> <input type="hidden" name="do" value="login" /> <input type="hidden" name="vb_login_md5password" value="" /> <input type="hidden" name="vb_login_md5password_utf" value="" /> <?php echo $postvars; ?> <p> </p><p> </p> <table class="tborder" cellpadding="0" cellspacing="0" border="0" width="450" align="center"><tr><td> <!-- header --> <div class="tcat" style="padding:4px; text-align:center"><b><?php echo $vbphrase['log_in']; ?> </b></div> <!-- /header --> <!-- logo and version --> <table cellpadding="4" cellspacing="0" border="0" width="100%" class="navbody"> <tr valign="bottom"> <td><img src="../cpstyles/<?php echo $vbulletin->options['cpstylefolder']; ?> /cp_logo.gif" alt="" title="<?php echo $vbphrase['vbulletin_copyright']; ?> " border="0" /></td> <td> <b><a href="../<?php echo $vbulletin->options['forumhome']; ?> .php"><?php echo $vbulletin->options['bbtitle']; ?> </a></b><br /> <?php echo "vBulletin " . $vbulletin->options['templateversion'] . " {$pagetitle}"; ?> <br /> </td> </tr> <?php if ($mismatch) { ?> <tr> <td colspan="2" class="navbody"><b><?php echo $vbphrase['to_continue_this_action']; ?> </b></td> </tr> <?php } ?> </table> <!-- /logo and version --> <table cellpadding="4" cellspacing="0" border="0" width="100%" class="logincontrols"> <col width="50%" style="text-align:<?php echo $stylevar['right']; ?> ; white-space:nowrap"></col> <col></col> <col width="50%"></col> <!-- login fields --> <tbody> <tr> <td><?php echo $vbphrase['username']; ?> </td> <td><input type="text" style="padding-<?php echo $stylevar['left']; ?> :5px; font-weight:bold; width:250px" name="vb_login_username" value="<?php echo $printusername; ?> " accesskey="u" tabindex="1" id="vb_login_username" /></td> <td> </td> </tr> <tr> <td><?php echo $vbphrase['password']; ?> </td> <td><input type="password" style="padding-<?php echo $stylevar['left']; ?> :5px; font-weight:bold; width:250px" name="vb_login_password" accesskey="p" tabindex="2" id="vb_login_password" /></td> <td> </td> </tr> <tr style="display: none" id="cap_lock_alert"> <td> </td> <td class="tborder"><?php echo $vbphrase['caps_lock_is_on']; ?> </td> <td> </td> </tr> </tbody> <!-- /login fields --> <?php if ($showoptions) { ?> <!-- admin options --> <tbody id="loginoptions" style="display:none"> <tr> <td><?php echo $vbphrase['style']; ?> </td> <td><select name="cssprefs" class="login" style="padding-<?php echo $stylevar['left']; ?> :5px; font-weight:normal; width:250px" tabindex="5"><?php echo construct_select_options($cssoptions, $csschoice); ?> </select></td> <td> </td> </tr> <tr> <td><?php echo $vbphrase['options']; ?> </td> <td> <input type="checkbox" name="nojs" value="1" tabindex="6" /><?php echo $vbphrase['save_open_groups_automatically']; ?> </td> <td class="login"> </td> </tr> </tbody> <!-- /admin options --> <?php } ?> <!-- submit row --> <tbody> <tr> <td colspan="3" align="center"> <input type="submit" class="button" value=" <?php echo $vbphrase['log_in']; ?> " accesskey="s" tabindex="3" /> <?php if ($showoptions) { ?> <input type="button" class="button" value=" <?php echo $vbphrase['options']; ?> " accesskey="o" onclick="js_show_options('loginoptions', this)" tabindex="4" /><?php } ?> </td> </tr> </tbody> <!-- /submit row --> </table> </td></tr></table> </form> <script type="text/javascript"> <!-- function caps_check(e) { var detected_on = detect_caps_lock(e); var alert_box = fetch_object('cap_lock_alert'); if (alert_box.style.display == '') { // box showing already, hide if caps lock turns off if (!detected_on) { alert_box.style.display = 'none'; } } else { if (detected_on) { alert_box.style.display = ''; } } } fetch_object('vb_login_password').onkeypress = caps_check; //--> </script> <?php define('NO_CP_COPYRIGHT', true); unset($GLOBALS['DEVDEBUG']); print_cp_footer(); }
/** * 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&varname={$setting['varname']}") . construct_link_code($vbphrase['delete'], "options.php?" . $vbulletin->session->vars['sessionurl'] . "do=removesetting&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>"; }
/** * 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&varname={$setting['varname']}") . construct_link_code($vbphrase['delete'], "options.php?" . $vbulletin->session->vars['sessionurl'] . "do=removesetting&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>"; }
/** * 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&varname={$setting['varname']}") . construct_link_code($vbphrase['delete'], "options.php?" . vB::getCurrentSession()->get('sessionurl') . "do=removesetting&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>"; }
/** * Displays the login form for the various control panel areas * * The actual form displayed is dependent upon the VB_AREA constant */ function print_cp_login($mismatch = false) { global $vbulletin, $vbphrase; if ($vbulletin->GPC['ajax']) { print_stop_message2('you_have_been_logged_out_of_the_cp'); } $focusfield = iif($vbulletin->userinfo['userid'] == 0, 'username', 'password'); $vbulletin->input->clean_array_gpc('r', array('vb_login_username' => vB_Cleaner::TYPE_NOHTML, 'loginerror' => vB_Cleaner::TYPE_STR, 'strikes' => vB_Cleaner::TYPE_INT)); $printusername = iif(!empty($vbulletin->GPC['vb_login_username']), $vbulletin->GPC['vb_login_username'], $vbulletin->userinfo['userid'] ? $vbulletin->userinfo['username'] : ''); $vbulletin->userinfo['badlocation'] = 1; $options = vB::getDatastore()->getValue('options'); $filebase = $options['bburl']; switch (VB_AREA) { case 'AdminCP': $pagetitle = $vbphrase['admin_control_panel']; $getcssoptions = fetch_cpcss_options(); $cssoptions = array(); foreach ($getcssoptions as $folder => $foldername) { $key = iif($folder == $options['cpstylefolder'], '', $folder); $cssoptions["{$key}"] = $foldername; } $showoptions = true; $logintype = 'cplogin'; break; case 'ModCP': $pagetitle = $vbphrase['moderator_control_panel']; $showoptions = false; $logintype = 'modcplogin'; break; default: // Legacy Hook 'admin_login_area_switch' Removed // } define('NO_PAGE_TITLE', true); print_cp_header($vbphrase['log_in'], "document.forms.loginform.vb_login_{$focusfield}.focus()"); require_once DIR . '/includes/functions_misc.php'; $postvars = construct_post_vars_html(); $forumHome = vB_Library::instance('content_channel')->getForumHomeChannel(); $forumhome_url = vB5_Route::buildUrl($forumHome['routeid'] . '|fullurl'); if (strpos('://', $forumhome_url) == 'false') { $forumhome_url = '../' . $forumhome_url; } ?> <script type="text/javascript" src="<?php echo $filebase; ?> /clientscript/vbulletin_md5.js?v=<?php echo SIMPLE_VERSION; ?> "></script> <script type="text/javascript"> <!-- function js_show_options(objectid, clickedelm) { fetch_object(objectid).style.display = ""; clickedelm.disabled = true; } function js_fetch_url_append(origbit,addbit) { if (origbit.search(/\?/) != -1) { return origbit + '&' + addbit; } else { return origbit + '?' + addbit; } } function js_do_options(formobj) { if (typeof(formobj.nojs) != "undefined" && formobj.nojs.checked == true) { formobj.url.value = js_fetch_url_append(formobj.url.value, 'nojs=1'); } return true; } //--> </script> <form action="../login.php?do=login" method="post" name="loginform" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf); js_do_options(this)"> <input type="hidden" name="url" value="<?php echo $vbulletin->scriptpath; ?> " /> <input type="hidden" name="s" value="<?php echo vB::getCurrentSession()->get('dbsessionhash'); ?> " /> <input type="hidden" name="securitytoken" value="<?php echo $vbulletin->userinfo['securitytoken']; ?> " /> <input type="hidden" name="logintype" value="<?php echo $logintype; ?> " /> <input type="hidden" name="do" value="login" /> <input type="hidden" name="vb_login_md5password" value="" /> <input type="hidden" name="vb_login_md5password_utf" value="" /> <?php echo $postvars; ?> <p> </p><p> </p> <table class="tborder" cellpadding="0" cellspacing="0" border="0" width="450" align="center"><tr><td> <!-- header --> <div class="tcat" style="text-align:center"><b><?php echo $vbphrase['log_in']; ?> </b></div> <!-- /header --> <!-- logo and version --> <table cellpadding="4" cellspacing="0" border="0" width="100%" class="login-logo"> <tr valign="bottom"> <td><img src="<?php echo $filebase; ?> /cpstyles/<?php echo $options['cpstylefolder']; ?> /cp_logo.<?php echo $options['cpstyleimageext']; ?> " title="<?php echo $vbphrase['vbulletin_copyright']; ?> " border="0" /></td> <td> <b><a href="<?php echo $forumhome_url; ?> "><?php echo $options['bbtitle']; ?> </a></b><br /> <?php echo "{$pagetitle}"; ?> <br /> </td> </tr> <?php if ($mismatch) { ?> <tr> <td colspan="2" class="navbody"><b><?php echo $vbphrase['to_continue_this_action']; ?> </b></td> </tr> <?php } if ($vbulletin->GPC['loginerror']) { $errorphrase = vB_Api::instanceInternal('phrase')->fetch($vbulletin->GPC['loginerror']); $errorphrase = $errorphrase[$vbulletin->GPC['loginerror']]; ?> <tr> <td colspan="2" class="navbody error"><b><?php echo construct_phrase($errorphrase, '../lostpw', $vbulletin->GPC['strikes']); ?> </b></td> </tr> <?php } ?> </table> <!-- /logo and version --> <table cellpadding="4" cellspacing="0" border="0" width="100%" class="alt1"> <col width="50%" style="text-align:<?php echo vB_Template_Runtime::fetchStyleVar('right'); ?> ; white-space:nowrap"></col> <col></col> <col width="50%"></col> <!-- login fields --> <tbody> <tr> <td><?php echo $vbphrase['username']; ?> </td> <td><input type="text" style="padding-<?php echo vB_Template_Runtime::fetchStyleVar('left'); ?> :5px; font-weight:bold; width:250px" name="vb_login_username" value="<?php echo $printusername; ?> " accesskey="u" tabindex="1" id="vb_login_username" /></td> <td> </td> </tr> <tr> <td><?php echo $vbphrase['password']; ?> </td> <td><input type="password" autocomplete="off" style="padding-<?php echo vB_Template_Runtime::fetchStyleVar('left'); ?> :5px; font-weight:bold; width:250px" name="vb_login_password" accesskey="p" tabindex="2" id="vb_login_password" /></td> <td> </td> </tr> <tr style="display: none" id="cap_lock_alert"> <td> </td> <td class="tborder"><?php echo $vbphrase['caps_lock_is_on']; ?> </td> <td> </td> </tr> </tbody> <!-- /login fields --> <?php if ($showoptions) { ?> <!-- admin options --> <tbody id="loginoptions" style="display:none"> <tr> <td><?php echo $vbphrase['style']; ?> </td> <td><select name="cssprefs" class="login" style="padding-<?php echo vB_Template_Runtime::fetchStyleVar('left'); ?> :5px; font-weight:normal; width:250px" tabindex="5"><?php echo construct_select_options($cssoptions, $csschoice); ?> </select></td> <td> </td> </tr> <tr> <td><?php echo $vbphrase['options']; ?> </td> <td> <label><input type="checkbox" name="nojs" value="1" tabindex="6" /> <?php echo $vbphrase['save_open_groups_automatically']; ?> </label> </td> <td class="login"> </td> </tr> </tbody> <!-- END admin options --> <?php } ?> <!-- submit row --> <tbody> <tr> <td colspan="3" align="center"> <input type="submit" class="button" value=" <?php echo $vbphrase['log_in']; ?> " accesskey="s" tabindex="3" /> <?php if ($showoptions) { ?> <input type="button" class="button" value=" <?php echo $vbphrase['options']; ?> " accesskey="o" onclick="js_show_options('loginoptions', this)" tabindex="4" /><?php } ?> </td> </tr> </tbody> <!-- /submit row --> </table> </td></tr></table> </form> <script type="text/javascript"> <!-- function caps_check(e) { var detected_on = detect_caps_lock(e); var alert_box = fetch_object('cap_lock_alert'); if (alert_box.style.display == '') { // box showing already, hide if caps lock turns off if (!detected_on) { alert_box.style.display = 'none'; } } else { if (detected_on) { alert_box.style.display = ''; } } } fetch_object('vb_login_password').onkeypress = caps_check; //--> </script> <?php define('NO_CP_COPYRIGHT', true); unset($GLOBALS['DEVDEBUG']); print_cp_footer(); }