当前位置: 首页>>代码示例>>PHP>>正文


PHP validate_config_vars函数代码示例

本文整理汇总了PHP中validate_config_vars函数的典型用法代码示例。如果您正苦于以下问题:PHP validate_config_vars函数的具体用法?PHP validate_config_vars怎么用?PHP validate_config_vars使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了validate_config_vars函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: settings

 function settings($id, $mode)
 {
     global $config, $db, $user, $auth, $template;
     global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
     $submit = isset($_POST['submit']) ? true : false;
     $action = request_var('action', '');
     $this->tpl_name = 'acp_board';
     $this->page_title = $user->lang['ACP_BLOGS'];
     blog_plugins::plugin_do('acp_main_start');
     $settings = array('legend0' => 'VERSION', 'user_blog_version' => array('lang' => 'VERSION', 'type' => 'custom', 'method' => 'blog_version', 'explain' => false), 'legend1' => 'BLOG_SETTINGS', 'user_blog_enable' => array('lang' => 'ENABLE_USER_BLOG', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'user_blog_enable_plugins' => array('lang' => 'ENABLE_USER_BLOG_PLUGINS', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'user_blog_subscription_enabled' => array('lang' => 'ENABLE_SUBSCRIPTIONS', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'user_blog_enable_zebra' => array('lang' => 'BLOG_ENABLE_ZEBRA', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'user_blog_seo' => array('lang' => 'BLOG_ENABLE_SEO', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'user_blog_search' => array('lang' => 'BLOG_ENABLE_SEARCH', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'user_blog_user_permissions' => array('lang' => 'BLOG_ENABLE_USER_PERMISSIONS', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'user_blog_enable_ratings' => array('lang' => 'BLOG_ENABLE_RATINGS', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'user_blog_enable_attachments' => array('lang' => 'BLOG_ENABLE_ATTACHMENTS', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'user_blog_enable_feeds' => array('lang' => 'BLOG_ENABLE_FEEDS', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => false), 'legend2' => 'BLOG_POST_VIEW_SETTINGS', 'user_blog_guest_captcha' => array('lang' => 'BLOG_GUEST_CAPTCHA', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'user_blog_custom_profile_enable' => array('lang' => 'ENABLE_BLOG_CUSTOM_PROFILES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'user_blog_links_output_block' => array('lang' => 'OUTPUT_CPLINKS_BLOCK', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'user_blog_always_show_blog_url' => array('lang' => 'BLOG_ALWAYS_SHOW_URL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'user_blog_text_limit' => array('lang' => 'DEFAULT_TEXT_LIMIT', 'validate' => 'int', 'type' => 'text:5:5', 'explain' => true), 'user_blog_user_text_limit' => array('lang' => 'USER_TEXT_LIMIT', 'validate' => 'int', 'type' => 'text:5:5', 'explain' => true), 'user_blog_inform' => array('lang' => 'BLOG_INFORM', 'validate' => 'string', 'type' => 'text:25:100', 'explain' => true), 'user_blog_message_from' => array('lang' => 'BLOG_MESSAGE_FROM', 'validate' => 'string', 'type' => 'text:5:5', 'explain' => true), 'user_blog_min_rating' => array('lang' => 'BLOG_MIN_RATING', 'validate' => 'int', 'type' => 'text:5:5', 'explain' => true), 'user_blog_max_rating' => array('lang' => 'BLOG_MAX_RATING', 'validate' => 'int', 'type' => 'text:5:5', 'explain' => true), 'user_blog_quick_reply' => array('lang' => 'BLOG_QUICK_REPLY', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'legend3' => 'BLOG_ATTACHMENT_SETTINGS', 'user_blog_max_attachments' => array('lang' => 'BLOG_MAX_ATTACHMENTS', 'validate' => 'int', 'type' => 'text:5:5', 'explain' => true));
     blog_plugins::plugin_do_ref('acp_main_settings', $settings);
     $this->new_config = $config;
     $cfg_array = isset($_REQUEST['config']) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config;
     $error = array();
     // We validate the complete config if whished
     validate_config_vars($settings, $cfg_array, $error);
     // Do not write values if there is an error
     if (sizeof($error)) {
         $submit = false;
     }
     $template->assign_vars(array('L_TITLE' => $user->lang['BLOG_SETTINGS'], 'L_TITLE_EXPLAIN' => $user->lang['BLOG_SETTINGS_EXPLAIN'], 'S_ERROR' => sizeof($error) ? true : false, 'ERROR_MSG' => implode('<br />', $error), 'U_ACTION' => $this->u_action));
     foreach ($settings as $config_key => $vars) {
         if ($submit) {
             if (!isset($cfg_array[$config_key]) || strpos($config_key, 'legend') !== false) {
                 continue;
             }
             $this->new_config[$config_key] = $config_value = $cfg_array[$config_key];
             set_config($config_key, $config_value);
         } else {
             if ((!is_array($vars) || !isset($this->new_config[$config_key])) && strpos($config_key, 'legend') === false) {
                 continue;
             }
             if (strpos($config_key, 'legend') !== false) {
                 $template->assign_block_vars('options', array('S_LEGEND' => true, 'LEGEND' => isset($user->lang[$vars]) ? $user->lang[$vars] : $vars));
                 continue;
             }
             $type = explode(':', $vars['type']);
             $l_explain = '';
             if ($vars['explain'] && isset($vars['lang_explain'])) {
                 $l_explain = isset($user->lang[$vars['lang_explain']]) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
             } else {
                 if ($vars['explain']) {
                     $l_explain = isset($user->lang[$vars['lang'] . '_EXPLAIN']) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
                 }
             }
             $template->assign_block_vars('options', array('KEY' => $config_key, 'TITLE' => isset($user->lang[$vars['lang']]) ? $user->lang[$vars['lang']] : $vars['lang'], 'S_EXPLAIN' => $vars['explain'], 'TITLE_EXPLAIN' => $l_explain, 'CONTENT' => build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars)));
         }
     }
     if ($submit) {
         add_log('admin', 'LOG_BLOG_CONFIG');
         trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
     }
 }
开发者ID:EXreaction,项目名称:User-Blog-Mod,代码行数:53,代码来源:acp_blogs.php

示例2: get_submitted_settings

 /**
  * @param array $default_settings
  * @return array|void
  */
 public function get_submitted_settings(array $default_settings)
 {
     if (!function_exists('validate_config_vars')) {
         include $this->phpbb_root_path . 'includes/functions_acp.' . $this->php_ext;
     }
     $cfg_array = utf8_normalize_nfc($this->request->variable('config', array('' => ''), true));
     $errors = array();
     validate_config_vars($default_settings, $cfg_array, $errors);
     if (sizeof($errors)) {
         return array('errors' => join("\n", $errors));
     }
     $this->_get_multi_select($cfg_array, $default_settings);
     return array_intersect_key($cfg_array, $default_settings);
 }
开发者ID:BogusCurry,项目名称:phpBB-ext-sitemaker,代码行数:18,代码来源:cfg_handler.php

示例3: blog_confirm

/**
* Build Confirm
*
* @param string $title The title of the page
* @param string $explain The explanation of the page
* @param array $display_vars The array holding all of the settings/information - like how admin_board is setup
* @param string $submit_type The type of submit buttons you want shown. Currently supported: 'submit/reset' or 'yes/no' 
* @param string $action The page you want to submit to.  Leave as self to be the current page.
*/
function blog_confirm($title, $explain, $display_vars, $submit_type = 'submit/reset', $action = 'self')
{
    global $template, $user;
    $submit = isset($_POST['submit']) ? true : false;
    $error = $settings = array();
    if ($submit) {
        // check the form key
        if (!check_form_key('confirm')) {
            $error[] = $user->lang['FORM_INVALID'];
        }
        $settings = request_var('setting', array('' => ''));
        validate_config_vars($display_vars, $settings, $error);
        if (!sizeof($error)) {
            return $settings;
        } else {
            $template->assign_vars(array('S_ERROR' => true, 'ERROR_MSG' => implode($error, '<br />')));
        }
    }
    // Add the form key
    add_form_key('confirm');
    if ($action === 'self') {
        global $blog_urls;
        if (isset($blog_urls['self'])) {
            $action = $blog_urls['self'];
        } else {
            $action = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];
        }
    }
    $template->assign_vars(array('L_TITLE' => isset($user->lang[$title]) ? $user->lang[$title] : $title, 'L_TITLE_EXPLAIN' => isset($user->lang[$explain]) ? $user->lang[$explain] : $explain, 'U_ACTION' => $action, 'S_YES_NO' => $submit_type == 'submit/reset' ? false : true));
    foreach ($display_vars as $key => $vars) {
        if (strpos($key, 'legend') !== false) {
            $template->assign_block_vars('options', array('S_LEGEND' => true, 'LEGEND' => isset($user->lang[$vars]) ? $user->lang[$vars] : $vars));
            continue;
        }
        $default = isset($settings[$key]) ? $settings[$key] : $vars['default'];
        $type = explode(':', $vars['type']);
        $l_explain = '';
        if ($vars['explain'] && isset($vars['lang_explain'])) {
            $l_explain = isset($user->lang[$vars['lang_explain']]) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
        } else {
            if ($vars['explain']) {
                $l_explain = isset($user->lang[$vars['lang'] . '_EXPLAIN']) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
            }
        }
        $template->assign_block_vars('options', array('KEY' => $key, 'TITLE' => isset($user->lang[$vars['lang']]) ? $user->lang[$vars['lang']] : $vars['lang'], 'S_EXPLAIN' => $vars['explain'], 'TITLE_EXPLAIN' => $l_explain, 'CONTENT' => build_blog_cfg_template($type, $key, $default)));
    }
    $template->set_filenames(array('body' => 'blog/blog_confirm.html'));
    return 'build';
}
开发者ID:EXreaction,项目名称:User-Blog-Mod,代码行数:58,代码来源:functions_confirm.php

示例4: main


//.........这里部分代码省略.........
         if ($db_tool->sql_table_exists($legacy_dbtable) || $db_tool->sql_table_exists($table_prefix . 'pbwow_config')) {
             $legacy_db_active = true;
         }
         // Check if topics table has been modded
         if ($db_tool->sql_column_exists(TOPICS_TABLE, 'topic_first_poster_rank_img') || $db_tool->sql_column_exists(TOPICS_TABLE, 'topic_first_poster_rank_title')) {
             $legacy_topics_mod = true;
         }
     }
     /**
      *	Validation types are:
      *		string, int, bool,
      *		script_path (absolute path in url - beginning with / and no trailing slash),
      *		rpath (relative), rwpath (realtive, writeable), path (relative path, but able to escape the root), wpath (writeable)
      */
     switch ($mode) {
         case 'overview':
             $display_vars = array('title' => 'ACP_PBWOW2_OVERVIEW_TITLE', 'vars' => array());
             break;
         case 'config':
             $display_vars = array('title' => 'ACP_PBWOW_CONFIG_TITLE', 'vars' => array('legend1' => 'ACP_PBWOW_LOGO', 'logo_size_width' => array('lang' => 'PBWOW_LOGO_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), 'logo_size_height' => array('lang' => 'PBWOW_LOGO_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), 'logo_enable' => array('lang' => 'PBWOW_LOGO_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'logo_src' => array('lang' => 'PBWOW_LOGO_SRC', 'validate' => 'string', 'type' => 'text:20:255', 'explain' => true), 'logo_size' => array('lang' => 'PBWOW_LOGO_SIZE', 'validate' => 'int:0', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 'logo_margins' => array('lang' => 'PBWOW_LOGO_MARGINS', 'validate' => 'string', 'type' => 'text:20:20', 'explain' => true), 'legend2' => 'ACP_PBWOW_TOPBAR', 'topbar_enable' => array('lang' => 'PBWOW_TOPBAR_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'topbar_code' => array('lang' => 'PBWOW_TOPBAR_CODE', 'type' => 'textarea:6:6', 'explain' => true), 'topbar_fixed' => array('lang' => 'PBWOW_TOPBAR_FIXED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'legend3' => 'ACP_PBWOW_HEADERLINKS', 'headerlinks_enable' => array('lang' => 'PBWOW_HEADERLINKS_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'headerlinks_code' => array('lang' => 'PBWOW_HEADERLINKS_CODE', 'type' => 'textarea:6:6', 'explain' => true), 'legend4' => 'ACP_PBWOW_NAVMENU', 'navmenu_enable' => array('lang' => 'PBWOW_NAVMENU_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'legend5' => 'ACP_PBWOW_IE6MESSAGE', 'ie6message_enable' => array('lang' => 'PBWOW_IE6MESSAGE_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'ie6message_code' => array('lang' => 'PBWOW_IE6MESSAGE_CODE', 'type' => 'textarea:6:6', 'explain' => true), 'legend6' => 'ACP_PBWOW_VIDEOBG', 'videobg_enable' => array('lang' => 'PBWOW_VIDEOBG_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'videobg_allpages' => array('lang' => 'PBWOW_VIDEOBG_ALLPAGES', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'bg_fixed' => array('lang' => 'PBWOW_BG_FIXED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'legend7' => 'ACP_PBWOW_BNETCHARS', 'bnetchars_enable' => array('lang' => 'PBWOW_BNETCHARS_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'bnetchars_cachetime' => array('lang' => 'PBWOW_BNETCHARS_CACHETIME', 'validate' => 'int:0', 'type' => 'text:6:6', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']), 'bnetchars_timeout' => array('lang' => 'PBWOW_BNETCHARS_TIMEOUT', 'validate' => 'int:0', 'type' => 'text:1:1', 'explain' => true, 'append' => ' ' . $user->lang['SECONDS']), 'legend8' => 'ACP_PBWOW_TOOLTIPS', 'wowtips_script' => array('lang' => 'PBWOW_WOWTIPS_SCRIPT', 'validate' => 'int', 'type' => 'custom', 'explain' => true, 'method' => 'select_single'), 'd3tips_script' => array('lang' => 'PBWOW_D3TIPS_SCRIPT', 'validate' => 'int', 'type' => 'custom', 'explain' => true, 'method' => 'select_single'), 'zamtips_enable' => array('lang' => 'PBWOW_ZAMTIPS_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'tooltips_region' => array('lang' => 'PBWOW_TOOLTIPS_REGION', 'validate' => 'int', 'type' => 'custom', 'explain' => true, 'method' => 'select_single'), 'tooltips_footer' => array('lang' => 'PBWOW_TOOLTIPS_FOOTER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'tooltips_local' => array('lang' => 'PBWOW_TOOLTIPS_LOCAL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true)));
             break;
         case 'poststyling':
             $display_vars = array('title' => 'ACP_PBWOW_POSTSTYLING_TITLE', 'vars' => array('legend1' => 'ACP_PBWOW_BLIZZ', 'blizz_enable' => array('lang' => 'PBWOW_BLIZZ_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'blizz_ranks' => array('lang' => 'PBWOW_BLIZZ_RANKS', 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'select_ranks'), 'blizz_color' => array('lang' => 'PBWOW_BLIZZ_COLOR', 'validate' => 'string', 'type' => 'text:7:7', 'explain' => true), 'legend2' => 'ACP_PBWOW_PROPASS', 'propass_enable' => array('lang' => 'PBWOW_PROPASS_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'propass_ranks' => array('lang' => 'PBWOW_PROPASS_RANKS', 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'select_ranks'), 'propass_color' => array('lang' => 'PBWOW_PROPASS_COLOR', 'validate' => 'string', 'type' => 'text:7:7', 'explain' => true), 'legend3' => 'ACP_PBWOW_RED', 'red_enable' => array('lang' => 'PBWOW_RED_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'red_ranks' => array('lang' => 'PBWOW_RED_RANKS', 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'select_ranks'), 'red_color' => array('lang' => 'PBWOW_RED_COLOR', 'validate' => 'string', 'type' => 'text:7:7', 'explain' => true), 'legend4' => 'ACP_PBWOW_GREEN', 'green_enable' => array('lang' => 'PBWOW_GREEN_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'green_ranks' => array('lang' => 'PBWOW_GREEN_RANKS', 'validate' => 'string', 'type' => 'custom', 'explain' => true, 'method' => 'select_ranks'), 'green_color' => array('lang' => 'PBWOW_GREEN_COLOR', 'validate' => 'string', 'type' => 'text:7:7', 'explain' => true)));
             break;
         case 'ads':
             $display_vars = array('title' => 'ACP_PBWOW_ADS_TITLE', 'vars' => array('legend1' => 'ACP_PBWOW_ADS_INDEX', 'ads_index_enable' => array('lang' => 'PBWOW_ADS_INDEX_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'ads_index_code' => array('lang' => 'PBWOW_ADS_INDEX_CODE', 'type' => 'textarea:6:6', 'explain' => true), 'legend2' => 'ACP_PBWOW_ADS_TOP', 'ads_top_enable' => array('lang' => 'PBWOW_ADS_TOP_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'ads_top_code' => array('lang' => 'PBWOW_ADS_TOP_CODE', 'type' => 'textarea:6:6', 'explain' => true), 'legend3' => 'ACP_PBWOW_ADS_BOTTOM', 'ads_bottom_enable' => array('lang' => 'PBWOW_ADS_BOTTOM_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'ads_bottom_code' => array('lang' => 'PBWOW_ADS_BOTTOM_CODE', 'type' => 'textarea:6:6', 'explain' => true), 'legend4' => 'ACP_PBWOW_ADS_SIDE', 'ads_side_enable' => array('lang' => 'PBWOW_ADS_SIDE_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'ads_side_code' => array('lang' => 'PBWOW_ADS_SIDE_CODE', 'type' => 'textarea:6:6', 'explain' => true), 'legend5' => 'ACP_PBWOW_TRACKING', 'tracking_enable' => array('lang' => 'PBWOW_TRACKING_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'tracking_code' => array('lang' => 'PBWOW_TRACKING_CODE', 'type' => 'textarea:6:6', 'explain' => true)));
             break;
     }
     $action = request_var('action', '');
     $submit = isset($_POST['submit']) ? true : false;
     $cfg_array = isset($_REQUEST['config']) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config;
     $error = array();
     // We validate the complete config if we want
     validate_config_vars($display_vars['vars'], $cfg_array, $error);
     // Do not write values if there is an error
     if (sizeof($error)) {
         $submit = false;
     }
     // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to... and then write to config
     foreach ($display_vars['vars'] as $config_name => $null) {
         if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) {
             continue;
         }
         $this->new_config[$config_name] = $config_value = $cfg_array[$config_name];
         if ($submit) {
             $this->set_pbwow_config($config_name, $config_value);
         }
     }
     if ($submit) {
         if ($action == 'refresh_topic_ranks' && $legacy_topics_mod == true) {
             $this->refresh_topic_ranks();
             $cache->purge();
         }
         if ($action == 'create_topic_ranks' && $legacy_topics_mod == false) {
             $db_tool->sql_column_add($topics_table, 'topic_first_poster_rank_img', array('VCHAR', ''));
             $db_tool->sql_column_add($topics_table, 'topic_first_poster_rank_title', array('VCHAR', ''));
             add_log('admin', 'Topics MOD installed', $user->lang['ACP_PBWOW2_' . strtoupper($mode)]);
             trigger_error('Topics MOD installed' . adm_back_link($this->u_action));
         }
         if (($action == 'drop_topic_ranks' || $action == 'remove_legacy') && $legacy_topics_mod == true) {
             $db_tool->sql_column_remove($topics_table, 'topic_first_poster_rank_img');
             $db_tool->sql_column_remove($topics_table, 'topic_first_poster_rank_title');
             add_log('admin', 'Topics MOD uninstalled', $user->lang['ACP_PBWOW2_' . strtoupper($mode)]);
             trigger_error('Topics MOD uninstalled' . adm_back_link($this->u_action));
         }
         if ($action == 'refresh_all_themes') {
开发者ID:gonzo1247,项目名称:hitman_roa,代码行数:67,代码来源:acp_pbwow2.php

示例5: generate_stuff_for_cfg_template

 /**
  * Abstracted method to generate acp configuration pages out of a list of display vars, using
  * the function build_cfg_template().
  * Build configuration template for acp configuration pages
  *
  * @param array $display_vars The display vars for this acp site
  */
 protected function generate_stuff_for_cfg_template($display_vars)
 {
     $this->new_config = $this->config;
     $cfg_array = $this->request->is_set('config') ? $this->request->variable('config', ['' => ''], true) : $this->new_config;
     $error = isset($error) ? $error : [];
     validate_config_vars($display_vars['vars'], $cfg_array, $error);
     foreach ($display_vars['vars'] as $config_key => $vars) {
         if (!is_array($vars) && strpos($config_key, 'legend') === false) {
             continue;
         }
         if (strpos($config_key, 'legend') !== false) {
             $this->template->assign_block_vars('options', ['S_LEGEND' => true, 'LEGEND' => isset($this->user->lang[$vars]) ? $this->user->lang[$vars] : $vars]);
             continue;
         }
         $type = explode(':', $vars['type']);
         $l_explain = '';
         if ($vars['explain'] && isset($vars['lang_explain'])) {
             $l_explain = isset($this->user->lang[$vars['lang_explain']]) ? $this->user->lang[$vars['lang_explain']] : $vars['lang_explain'];
         } else {
             if ($vars['explain']) {
                 $l_explain = isset($this->user->lang[$vars['lang'] . '_EXPLAIN']) ? $this->user->lang[$vars['lang'] . '_EXPLAIN'] : '';
             }
         }
         $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
         if (empty($content)) {
             continue;
         }
         $this->template->assign_block_vars('options', ['KEY' => $config_key, 'TITLE' => isset($this->user->lang[$vars['lang']]) ? $this->user->lang[$vars['lang']] : $vars['lang'], 'S_EXPLAIN' => $vars['explain'], 'TITLE_EXPLAIN' => $l_explain, 'CONTENT' => $content]);
         //unset($display_vars['vars'][$config_key]);
     }
     $this->template->assign_vars(['S_ERROR' => sizeof($error) ? true : false, 'ERROR_MSG' => implode('<br />', $error), 'U_ACTION' => $this->u_action]);
 }
开发者ID:Reaper88,项目名称:ajaxchat,代码行数:39,代码来源:ajaxchat_module.php

示例6: main

    function main($id, $mode)
    {
        global $db, $user, $auth, $template, $cache;
        global $config, $phpbb_admin_path, $phpbb_root_path, $phpEx;
        $user->add_lang(array('posting', 'viewtopic', 'acp/attachments'));
        $error = $notify = array();
        $submit = isset($_POST['submit']) ? true : false;
        $action = request_var('action', '');
        $form_key = 'acp_attach';
        add_form_key($form_key);
        if ($submit && !check_form_key($form_key)) {
            trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
        }
        switch ($mode) {
            case 'attach':
                $l_title = 'ACP_ATTACHMENT_SETTINGS';
                break;
            case 'extensions':
                $l_title = 'ACP_MANAGE_EXTENSIONS';
                break;
            case 'ext_groups':
                $l_title = 'ACP_EXTENSION_GROUPS';
                break;
            case 'orphan':
                $l_title = 'ACP_ORPHAN_ATTACHMENTS';
                break;
            default:
                trigger_error('NO_MODE', E_USER_ERROR);
                break;
        }
        $this->tpl_name = 'acp_attachments';
        $this->page_title = $l_title;
        $template->assign_vars(array('L_TITLE' => $user->lang[$l_title], 'L_TITLE_EXPLAIN' => $user->lang[$l_title . '_EXPLAIN'], 'U_ACTION' => $this->u_action));
        switch ($mode) {
            case 'attach':
                include_once $phpbb_root_path . 'includes/functions_posting.' . $phpEx;
                $sql = 'SELECT group_name, cat_id
					FROM ' . EXTENSION_GROUPS_TABLE . '
					WHERE cat_id > 0
					ORDER BY cat_id';
                $result = $db->sql_query($sql);
                $s_assigned_groups = array();
                while ($row = $db->sql_fetchrow($result)) {
                    $s_assigned_groups[$row['cat_id']][] = $row['group_name'];
                }
                $db->sql_freeresult($result);
                $l_legend_cat_images = $user->lang['SETTINGS_CAT_IMAGES'] . ' [' . $user->lang['ASSIGNED_GROUP'] . ': ' . (!empty($s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE]) ? implode(', ', $s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE]) : $user->lang['NO_EXT_GROUP']) . ']';
                $display_vars = array('title' => 'ACP_ATTACHMENT_SETTINGS', 'vars' => array('legend1' => 'ACP_ATTACHMENT_SETTINGS', 'img_max_width' => array('lang' => 'MAX_IMAGE_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), 'img_max_height' => array('lang' => 'MAX_IMAGE_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), 'img_link_width' => array('lang' => 'IMAGE_LINK_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), 'img_link_height' => array('lang' => 'IMAGE_LINK_SIZE', 'validate' => 'int:0', 'type' => false, 'method' => false, 'explain' => false), 'allow_attachments' => array('lang' => 'ALLOW_ATTACHMENTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'allow_pm_attach' => array('lang' => 'ALLOW_PM_ATTACHMENTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'upload_path' => array('lang' => 'UPLOAD_DIR', 'validate' => 'wpath', 'type' => 'text:25:100', 'explain' => true), 'display_order' => array('lang' => 'DISPLAY_ORDER', 'validate' => 'bool', 'type' => 'custom', 'method' => 'display_order', 'explain' => true), 'attachment_quota' => array('lang' => 'ATTACH_QUOTA', 'validate' => 'string', 'type' => 'custom', 'method' => 'max_filesize', 'explain' => true), 'max_filesize' => array('lang' => 'ATTACH_MAX_FILESIZE', 'validate' => 'string', 'type' => 'custom', 'method' => 'max_filesize', 'explain' => true), 'max_filesize_pm' => array('lang' => 'ATTACH_MAX_PM_FILESIZE', 'validate' => 'string', 'type' => 'custom', 'method' => 'max_filesize', 'explain' => true), 'max_attachments' => array('lang' => 'MAX_ATTACHMENTS', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => false), 'max_attachments_pm' => array('lang' => 'MAX_ATTACHMENTS_PM', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => false), 'secure_downloads' => array('lang' => 'SECURE_DOWNLOADS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'secure_allow_deny' => array('lang' => 'SECURE_ALLOW_DENY', 'validate' => 'int', 'type' => 'custom', 'method' => 'select_allow_deny', 'explain' => true), 'secure_allow_empty_referer' => array('lang' => 'SECURE_EMPTY_REFERRER', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'check_attachment_content' => array('lang' => 'CHECK_CONTENT', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'legend2' => $l_legend_cat_images, 'img_display_inlined' => array('lang' => 'DISPLAY_INLINED', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'img_create_thumbnail' => array('lang' => 'CREATE_THUMBNAIL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'img_max_thumb_width' => array('lang' => 'MAX_THUMB_WIDTH', 'validate' => 'int', 'type' => 'text:7:15', 'explain' => true, 'append' => ' px'), 'img_min_thumb_filesize' => array('lang' => 'MIN_THUMB_FILESIZE', 'validate' => 'int', 'type' => 'text:7:15', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']), 'img_imagick' => array('lang' => 'IMAGICK_PATH', 'validate' => 'string', 'type' => 'text:20:200', 'explain' => true, 'append' => '&nbsp;&nbsp;<span>[ <a href="' . $this->u_action . '&amp;action=imgmagick">' . $user->lang['SEARCH_IMAGICK'] . '</a> ]</span>'), 'img_max' => array('lang' => 'MAX_IMAGE_SIZE', 'validate' => 'int', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' px'), 'img_link' => array('lang' => 'IMAGE_LINK_SIZE', 'validate' => 'int', 'type' => 'dimension:3:4', 'explain' => true, 'append' => ' px')));
                $this->new_config = $config;
                $cfg_array = isset($_REQUEST['config']) ? request_var('config', array('' => '')) : $this->new_config;
                $error = array();
                // We validate the complete config if whished
                validate_config_vars($display_vars['vars'], $cfg_array, $error);
                // Do not write values if there is an error
                if (sizeof($error)) {
                    $submit = false;
                }
                // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
                foreach ($display_vars['vars'] as $config_name => $null) {
                    if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) {
                        continue;
                    }
                    $this->new_config[$config_name] = $config_value = $cfg_array[$config_name];
                    if (in_array($config_name, array('attachment_quota', 'max_filesize', 'max_filesize_pm'))) {
                        $size_var = request_var($config_name, '');
                        $this->new_config[$config_name] = $config_value = $size_var == 'kb' ? round($config_value * 1024) : ($size_var == 'mb' ? round($config_value * 1048576) : $config_value);
                    }
                    if ($submit) {
                        set_config($config_name, $config_value);
                    }
                }
                $this->perform_site_list();
                if ($submit) {
                    add_log('admin', 'LOG_CONFIG_ATTACH');
                    // Check Settings
                    $this->test_upload($error, $this->new_config['upload_path'], false);
                    if (!sizeof($error)) {
                        trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
                    }
                }
                $template->assign_var('S_ATTACHMENT_SETTINGS', true);
                if ($action == 'imgmagick') {
                    $this->new_config['img_imagick'] = $this->search_imagemagick();
                }
                // We strip eventually manual added convert program, we only want the patch
                if ($this->new_config['img_imagick']) {
                    // Change path separator
                    $this->new_config['img_imagick'] = str_replace('\\', '/', $this->new_config['img_imagick']);
                    $this->new_config['img_imagick'] = str_replace(array('convert', '.exe'), array('', ''), $this->new_config['img_imagick']);
                    // Check for trailing slash
                    if (substr($this->new_config['img_imagick'], -1) !== '/') {
                        $this->new_config['img_imagick'] .= '/';
                    }
                }
                $supported_types = get_supported_image_types();
                // Check Thumbnail Support
                if (!$this->new_config['img_imagick'] && (!isset($supported_types['format']) || !sizeof($supported_types['format']))) {
                    $this->new_config['img_create_thumbnail'] = 0;
                }
                $template->assign_vars(array('U_SEARCH_IMAGICK' => $this->u_action . '&amp;action=imgmagick', 'S_THUMBNAIL_SUPPORT' => !$this->new_config['img_imagick'] && (!isset($supported_types['format']) || !sizeof($supported_types['format'])) ? false : true));
//.........这里部分代码省略.........
开发者ID:jvinhit,项目名称:php,代码行数:101,代码来源:acp_attachments.php

示例7: main

 function main($id, $mode)
 {
     global $db, $user, $auth, $template;
     global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
     $action = request_var('action', '');
     $submit = isset($_POST['submit']) ? true : false;
     $form_key = 'acp_thanks_reput';
     add_form_key($form_key);
     /**
      *	Validation types are:
      *		string, int, bool,
      *		script_path (absolute path in url - beginning with / and no trailing slash),
      *		rpath (relative), rwpath (realtive, writable), path (relative path, but able to escape the root), wpath (writable)
      */
     $display_vars = array('title' => 'ACP_THANKS_REPUT_SETTINGS', 'vars' => array('legend' => 'GENERAL_OPTIONS', 'thanks_post_reput_view' => array('lang' => 'THANKS_POST_REPUT_VIEW', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'thanks_topic_reput_view' => array('lang' => 'THANKS_TOPIC_REPUT_VIEW', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'thanks_topic_reput_view_column' => array('lang' => 'THANKS_TOPIC_REPUT_VIEW_COLUMN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'thanks_forum_reput_view' => array('lang' => 'THANKS_FORUM_REPUT_VIEW', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'thanks_forum_reput_view_column' => array('lang' => 'THANKS_FORUM_REPUT_VIEW_COLUMN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'thanks_number_digits' => array('lang' => 'THANKS_NUMBER_DIGITS', 'validate' => 'int:0', 'type' => 'text:4:4', 'explain' => false), 'thanks_number_row_reput' => array('lang' => 'THANKS_NUMBER_ROW_REPUT', 'validate' => 'int:0', 'type' => 'text:4:6', 'explain' => true), 'legend1' => 'GRAPHIC_OPTIONS', 'thanks_reput_graphic' => array('lang' => 'THANKS_REPUT_GRAPHIC', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'thanks_reput_height' => array('lang' => 'THANKS_REPUT_HEIGHT', 'validate' => 'int:1:25', 'type' => 'text:4:6', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 'thanks_reput_level' => array('lang' => 'THANKS_REPUT_LEVEL', 'validate' => 'int:4:13', 'type' => 'text:4:4', 'explain' => false), 'thanks_reput_image' => array('lang' => 'THANKS_REPUT_IMAGE', 'validate' => 'string', 'type' => 'text:25:255', 'explain' => true, 'append' => '<br /><img src="' . ($config['thanks_reput_image'] ? $phpbb_root_path . $config['thanks_reput_image'] : '') . '" alt="' . $user->lang['THANKS_REPUT_IMAGE'] . '"/>'), 'thanks_reput_image_back' => array('lang' => 'THANKS_REPUT_IMAGE_BACK', 'validate' => 'string', 'type' => 'text:25:255', 'explain' => true, 'append' => '<br /><img src="' . ($config['thanks_reput_image_back'] ? $phpbb_root_path . $config['thanks_reput_image_back'] : '') . '" alt="' . $user->lang['THANKS_REPUT_IMAGE_BACK'] . '"/>'), 'legend2' => 'GRAPHIC_DEFAULT'));
     if (isset($display_vars['lang'])) {
         $user->add_lang($display_vars['lang']);
     }
     $this->new_config = $config;
     $cfg_array = isset($_REQUEST['config']) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config;
     $error = array();
     // We validate the complete config if whished
     validate_config_vars($display_vars['vars'], $cfg_array, $error);
     if ($submit && !check_form_key($form_key)) {
         $error[] = $user->lang['FORM_INVALID'];
     }
     // Do not write values if there is an error
     if (sizeof($error)) {
         $submit = false;
     }
     if (!empty($cfg_array['thanks_reput_image']) && !file_exists($phpbb_root_path . $config['thanks_reput_image'])) {
         $error[] = $user->lang['THANKS_REPUT_IMAGE_NOEXIST'];
     }
     if (!empty($cfg_array['thanks_reput_image_back']) && !file_exists($phpbb_root_path . $config['thanks_reput_image_back'])) {
         $error[] = $user->lang['THANKS_REPUT_IMAGE_BACK_NOEXIST'];
     }
     // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
     foreach ($display_vars['vars'] as $config_name => $null) {
         if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) {
             continue;
         }
         $this->new_config[$config_name] = $config_value = $cfg_array[$config_name];
         if ($submit) {
             set_config($config_name, $config_value);
         }
     }
     if ($submit) {
         add_log('admin', 'LOG_CONFIG_' . strtoupper($mode));
         trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
     }
     $this->tpl_name = 'acp_thanks_reput';
     $this->page_title = $display_vars['title'];
     $template->assign_vars(array('L_TITLE' => $user->lang[$display_vars['title']], 'L_TITLE_EXPLAIN' => $user->lang[$display_vars['title'] . '_EXPLAIN'], 'GRAPHIC_STAR_BLUE_EXAMPLE' => $phpbb_root_path . $user->lang['GRAPHIC_STAR_BLUE'], 'GRAPHIC_STAR_GOLD_EXAMPLE' => $phpbb_root_path . $user->lang['GRAPHIC_STAR_GOLD'], 'GRAPHIC_STAR_BACK_EXAMPLE' => $phpbb_root_path . $user->lang['GRAPHIC_STAR_BACK'], 'GRAPHIC_BLOCK_RED_EXAMPLE' => $phpbb_root_path . $user->lang['GRAPHIC_BLOCK_RED'], 'GRAPHIC_BLOCK_BACK_EXAMPLE' => $phpbb_root_path . $user->lang['GRAPHIC_BLOCK_BACK'], 'S_ERROR' => sizeof($error) ? true : false, 'ERROR_MSG' => implode('<br />', $error), 'U_ACTION' => $this->u_action));
     // Output relevant page
     foreach ($display_vars['vars'] as $config_key => $vars) {
         if (!is_array($vars) && strpos($config_key, 'legend') === false) {
             continue;
         }
         if (strpos($config_key, 'legend') !== false) {
             $template->assign_block_vars('options', array('S_LEGEND' => true, 'LEGEND' => isset($user->lang[$vars]) ? $user->lang[$vars] : $vars));
             continue;
         }
         $type = explode(':', $vars['type']);
         $l_explain = '';
         if ($vars['explain'] && isset($vars['lang_explain'])) {
             $l_explain = isset($user->lang[$vars['lang_explain']]) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
         } else {
             if ($vars['explain']) {
                 $l_explain = isset($user->lang[$vars['lang'] . '_EXPLAIN']) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
             }
         }
         $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
         if (empty($content)) {
             continue;
         }
         $template->assign_block_vars('options', array('KEY' => $config_key, 'TITLE' => isset($user->lang[$vars['lang']]) ? $user->lang[$vars['lang']] : $vars['lang'], 'S_EXPLAIN' => $vars['explain'], 'TITLE_EXPLAIN' => $l_explain, 'CONTENT' => $content));
         unset($display_vars['vars'][$config_key]);
     }
 }
开发者ID:jsib,项目名称:intranet,代码行数:79,代码来源:acp_thanks_reput.php

示例8: main

 function main($id, $mode)
 {
     global $config, $user, $template, $request, $phpbb_container;
     $this->user = $user;
     $this->tpl_name = 'acp_board';
     $this->page_title = 'ACP_PMWELCOME_SETTINGS';
     $submit = $request->is_set_post('submit');
     $form_key = 'pmwelcome';
     add_form_key($form_key);
     $display_vars = array('title' => 'ACP_PMWELCOME', 'vars' => array('legend1' => 'ACP_PMWELCOME_SETTINGS', 'pmwelcome_user' => array('lang' => 'ACP_PMWELCOME_USER', 'validate' => 'int:0:255', 'type' => 'number:0:255', 'explain' => true), 'pmwelcome_subject' => array('lang' => 'ACP_PMWELCOME_SUBJECT', 'validate' => 'string', 'type' => 'text:50:250', 'explain' => false), 'pmwelcome_post_text' => array('lang' => 'ACP_PMWELCOME_TEXT', 'validate' => '', 'type' => 'textarea:15:30', 'explain' => true), 'legend2' => 'ACP_SUBMIT_CHANGES'));
     if (isset($display_vars['lang'])) {
         $user->add_lang($display_vars['lang']);
     }
     $this->new_config = $config;
     $cfg_array = $request->is_set('config') ? utf8_normalize_nfc($request->variable('config', array('' => ''), true)) : $this->new_config;
     $error = array();
     // We validate the complete config if wished
     validate_config_vars($display_vars['vars'], $cfg_array, $error);
     if ($submit && !check_form_key($form_key)) {
         $error[] = $user->lang['FORM_INVALID'];
     }
     // Do not write values if there is an error
     if (sizeof($error)) {
         $submit = false;
     }
     /* config text class && Anvar */
     $config_text = $phpbb_container->get('config_text');
     $text_ary = array('pmwelcome_post_text');
     // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
     foreach ($display_vars['vars'] as $config_name => $null) {
         if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) {
             continue;
         }
         $this->new_config[$config_name] = $config_value = $cfg_array[$config_name];
         if ($submit) {
             /* Add config text && Anvar */
             if (in_array($config_name, $text_ary)) {
                 $config_text->set($config_name, $config_value);
             } else {
                 $config->set($config_name, $config_value);
             }
         }
     }
     if ($submit) {
         trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
     }
     $this->page_title = $display_vars['title'];
     $template->assign_vars(array('L_TITLE' => $user->lang[$display_vars['title']], 'L_TITLE_EXPLAIN' => $user->lang[$display_vars['title'] . '_EXPLAIN'], 'S_ERROR' => sizeof($error) ? true : false, 'ERROR_MSG' => implode('<br />', $error), 'U_ACTION' => $this->u_action));
     // Output relevant page
     foreach ($display_vars['vars'] as $config_key => $vars) {
         if (!is_array($vars) && strpos($config_key, 'legend') === false) {
             continue;
         }
         if (strpos($config_key, 'legend') !== false) {
             $template->assign_block_vars('options', array('S_LEGEND' => true, 'LEGEND' => isset($user->lang[$vars]) ? $user->lang[$vars] : $vars));
             continue;
         }
         $type = explode(':', $vars['type']);
         $l_explain = '';
         if ($vars['explain'] && isset($vars['lang_explain'])) {
             $l_explain = isset($user->lang[$vars['lang_explain']]) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
         } else {
             if ($vars['explain']) {
                 $l_explain = isset($user->lang[$vars['lang'] . '_EXPLAIN']) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
             }
         }
         /* Get config text && Anvar */
         if (in_array($config_key, $text_ary)) {
             $this->new_config[$config_key] = $config_text->get($config_key);
         }
         $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
         if (empty($content)) {
             continue;
         }
         $template->assign_block_vars('options', array('KEY' => $config_key, 'TITLE' => isset($user->lang[$vars['lang']]) ? $user->lang[$vars['lang']] : $vars['lang'], 'S_EXPLAIN' => $vars['explain'], 'TITLE_EXPLAIN' => $l_explain, 'CONTENT' => $content));
         unset($display_vars['vars'][$config_key]);
     }
 }
开发者ID:Galixte,项目名称:apwa,代码行数:78,代码来源:pmwelcome_module.php

示例9: main

 function main($id, $mode)
 {
     global $config, $request, $template, $user;
     $this->page_title = 'ACP_POSTS_MERGING';
     $this->tpl_name = 'acp_posts_merging';
     $submit = isset($_POST['submit']) ? true : false;
     $form_key = 'config_posts_merging';
     add_form_key($form_key);
     $display_vars = array('title' => 'ACP_POSTS_MERGING', 'vars' => array('legend1' => 'ACP_POSTS_MERGING', 'merge_interval' => array('lang' => 'MERGE_INTERVAL', 'validate' => 'int', 'type' => 'text:3:4', 'explain' => true, 'append' => ' ' . $user->lang['HOURS']), 'merge_no_forums' => array('lang' => 'MERGE_NO_FORUMS', 'validate' => 'string', 'type' => 'text:5:255', 'explain' => true), 'merge_no_topics' => array('lang' => 'MERGE_NO_TOPICS', 'validate' => 'string', 'type' => 'text:5:255', 'explain' => true), 'legend2' => 'ACP_SUBMIT_CHANGES'));
     if (isset($display_vars['lang'])) {
         $user->add_lang($display_vars['lang']);
     }
     $this->new_config = $config;
     $cfg_array = isset($_REQUEST['config']) ? utf8_normalize_nfc($request->variable('config', array('' => ''), true)) : $this->new_config;
     $error = array();
     // We validate the complete config if wished
     validate_config_vars($display_vars['vars'], $cfg_array, $error);
     if ($submit && !check_form_key($form_key)) {
         $error[] = $user->lang['FORM_INVALID'];
     }
     // Do not write values if there is an error
     if (sizeof($error)) {
         $submit = false;
     }
     // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
     foreach ($display_vars['vars'] as $config_name => $null) {
         if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) {
             continue;
         }
         $this->new_config[$config_name] = $config_value = $cfg_array[$config_name];
         if ($submit) {
             $config->set($config_name, $config_value);
         }
     }
     if ($submit) {
         trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
     }
     // Output relevant page
     foreach ($display_vars['vars'] as $config_key => $vars) {
         if (!is_array($vars) && strpos($config_key, 'legend') === false) {
             continue;
         }
         if (strpos($config_key, 'legend') !== false) {
             $template->assign_block_vars('options', array('S_LEGEND' => true, 'LEGEND' => isset($user->lang[$vars]) ? $user->lang[$vars] : $vars));
             continue;
         }
         $type = explode(':', $vars['type']);
         $l_explain = '';
         if ($vars['explain'] && isset($vars['lang_explain'])) {
             $l_explain = isset($user->lang[$vars['lang_explain']]) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
         } else {
             if ($vars['explain']) {
                 $l_explain = isset($user->lang[$vars['lang'] . '_EXPLAIN']) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
             }
         }
         $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
         if (empty($content)) {
             continue;
         }
         $template->assign_block_vars('options', array('KEY' => $config_key, 'TITLE' => isset($user->lang[$vars['lang']]) ? $user->lang[$vars['lang']] : $vars['lang'], 'S_EXPLAIN' => $vars['explain'], 'TITLE_EXPLAIN' => $l_explain, 'CONTENT' => $content));
         unset($display_vars['vars'][$config_key]);
     }
 }
开发者ID:phpbb-store,项目名称:OfficeForum,代码行数:63,代码来源:posts_merging_module.php

示例10: saveConfig

 function saveConfig($display_vars)
 {
     global $db, $user, $auth, $template, $config, $error;
     if (!is_array($error)) {
         $error = array();
     }
     $submit = request_var('submit', '');
     $form_key = 'acp_raidattendance';
     add_form_key($form_key);
     if (isset($display_vars['lang'])) {
         $user->add_lang($display_vars['lang']);
     }
     $this->new_config = $config;
     $cfg_array = request_var('config', array('' => ''));
     $cfg_array = sizeof($cfg_array) > 1 ? utf8_normalize_nfc($cfg_array) : $this->new_config;
     // We validate the complete config if whished
     validate_config_vars($display_vars['vars'], $cfg_array, $error);
     if ($submit && !check_form_key($form_key)) {
         $error[] = $user->lang['FORM_INVALID'];
     }
     // Do not write values if there is an error
     if (sizeof($error)) {
         $submit = false;
     }
     // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
     // Add the "names"...
     foreach ($display_vars['vars'] as $config_name => $null) {
         if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) {
             continue;
         }
         if ($config_name == 'auth_method') {
             continue;
         }
         $this->new_config[$config_name] = $config_value = $cfg_array[$config_name];
         if ($submit) {
             set_config($config_name, $config_value);
         }
     }
     // Save non-"normal" configs
     if ($submit) {
         for ($ix = 0; $ix < 10; ++$ix) {
             $config_name = 'raidattendance_raider_rank' . $ix . '_name';
             $config_value = $cfg_array[$config_name];
             set_config($config_name, $config_value);
         }
         // save the raids
         $this->saveRaidSetup();
         add_log('admin', 'LOG_CONFIG_RAIDATTENDANCE_SETTINGS');
         trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
     }
     $this->page_title = $display_vars['title'];
     $template->assign_vars(array('L_TITLE' => $user->lang[$display_vars['title']], 'L_TITLE_EXPLAIN' => $user->lang[$display_vars['title'] . '_EXPLAIN'], 'S_ERROR' => sizeof($error) ? true : false, 'ERROR_MSG' => implode('<br />', $error), 'U_ACTION' => $this->u_action));
     // Output relevant page
     foreach ($display_vars['vars'] as $config_key => $vars) {
         if (!is_array($vars) && strpos($config_key, 'legend') === false) {
             continue;
         }
         if (strpos($config_key, 'legend') !== false) {
             $template->assign_block_vars('options', array('S_LEGEND' => true, 'LEGEND' => isset($user->lang[$vars]) ? $user->lang[$vars] : $vars));
             continue;
         }
         $type = explode(':', $vars['type']);
         $l_explain = '';
         if ($vars['explain'] && isset($vars['lang_explain'])) {
             $l_explain = isset($user->lang[$vars['lang_explain']]) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
         } else {
             if ($vars['explain']) {
                 $l_explain = isset($user->lang[$vars['lang'] . '_EXPLAIN']) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
             }
         }
         $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
         if (empty($content)) {
             continue;
         }
         $template->assign_block_vars('options', array('KEY' => $config_key, 'TITLE' => isset($user->lang[$vars['lang']]) ? $user->lang[$vars['lang']] : $vars['lang'], 'S_EXPLAIN' => $vars['explain'], 'TITLE_EXPLAIN' => $l_explain, 'CONTENT' => $content));
         unset($display_vars['vars'][$config_key]);
     }
 }
开发者ID:rlf,项目名称:raidattendance,代码行数:78,代码来源:acp_raidattendance.php

示例11: main

 function main($id, $mode)
 {
     global $request, $user, $auth, $template;
     global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx, $phpbb_container;
     $user->add_lang('acp/board');
     $factory = $phpbb_container->get('captcha.factory');
     $captchas = $factory->get_captcha_types();
     $selected = request_var('select_captcha', $config['captcha_plugin']);
     $selected = isset($captchas['available'][$selected]) || isset($captchas['unavailable'][$selected]) ? $selected : $config['captcha_plugin'];
     $configure = request_var('configure', false);
     // Oh, they are just here for the view
     if (isset($_GET['captcha_demo'])) {
         $this->deliver_demo($selected);
     }
     // Delegate
     if ($configure) {
         $config_captcha = $factory->get_instance($selected);
         $config_captcha->acp_page($id, $this);
     } else {
         $config_vars = array('enable_confirm' => array('tpl' => 'REG_ENABLE', 'default' => false, 'validate' => 'bool', 'lang' => 'VISUAL_CONFIRM_REG'), 'enable_post_confirm' => array('tpl' => 'POST_ENABLE', 'default' => false, 'validate' => 'bool', 'lang' => 'VISUAL_CONFIRM_POST'), 'confirm_refresh' => array('tpl' => 'CONFIRM_REFRESH', 'default' => false, 'validate' => 'bool', 'lang' => 'VISUAL_CONFIRM_REFRESH'), 'max_reg_attempts' => array('tpl' => 'REG_LIMIT', 'default' => 0, 'validate' => 'int:0:99999', 'lang' => 'REG_LIMIT'), 'max_login_attempts' => array('tpl' => 'MAX_LOGIN_ATTEMPTS', 'default' => 0, 'validate' => 'int:0:99999', 'lang' => 'MAX_LOGIN_ATTEMPTS'));
         $this->tpl_name = 'acp_captcha';
         $this->page_title = 'ACP_VC_SETTINGS';
         $form_key = 'acp_captcha';
         add_form_key($form_key);
         $submit = request_var('main_submit', false);
         $error = $cfg_array = array();
         if ($submit) {
             foreach ($config_vars as $config_var => $options) {
                 $cfg_array[$config_var] = $request->variable($config_var, $options['default']);
             }
             validate_config_vars($config_vars, $cfg_array, $error);
             if (!check_form_key($form_key)) {
                 $error[] = $user->lang['FORM_INVALID'];
             }
             if ($error) {
                 $submit = false;
             }
         }
         if ($submit) {
             foreach ($cfg_array as $key => $value) {
                 $config->set($key, $value);
             }
             if ($selected !== $config['captcha_plugin']) {
                 // sanity check
                 if (isset($captchas['available'][$selected])) {
                     $old_captcha = $factory->get_instance($config['captcha_plugin']);
                     $old_captcha->uninstall();
                     set_config('captcha_plugin', $selected);
                     $new_captcha = $factory->get_instance($config['captcha_plugin']);
                     $new_captcha->install();
                     add_log('admin', 'LOG_CONFIG_VISUAL');
                 } else {
                     trigger_error($user->lang['CAPTCHA_UNAVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
                 }
             }
             trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
         } else {
             $captcha_select = '';
             foreach ($captchas['available'] as $value => $title) {
                 $current = $selected !== false && $value == $selected ? ' selected="selected"' : '';
                 $captcha_select .= '<option value="' . $value . '"' . $current . '>' . $user->lang($title) . '</option>';
             }
             foreach ($captchas['unavailable'] as $value => $title) {
                 $current = $selected !== false && $value == $selected ? ' selected="selected"' : '';
                 $captcha_select .= '<option value="' . $value . '"' . $current . ' class="disabled-option">' . $user->lang($title) . '</option>';
             }
             $demo_captcha = $factory->get_instance($selected);
             foreach ($config_vars as $config_var => $options) {
                 $template->assign_var($options['tpl'], isset($_POST[$config_var]) ? request_var($config_var, $options['default']) : $config[$config_var]);
             }
             $template->assign_vars(array('CAPTCHA_PREVIEW_TPL' => $demo_captcha->get_demo_template($id), 'S_CAPTCHA_HAS_CONFIG' => $demo_captcha->has_config(), 'CAPTCHA_SELECT' => $captcha_select, 'ERROR_MSG' => implode('<br />', $error), 'U_ACTION' => $this->u_action));
         }
     }
 }
开发者ID:WarriorMachines,项目名称:warriormachines-phpbb,代码行数:74,代码来源:acp_captcha.php

示例12: test_validate_path_windows

 /**
  * @dataProvider data_validate_path_windows
  */
 public function test_validate_path_windows($path, $validation_type, $expected)
 {
     if (strtolower(substr(PHP_OS, 0, 3)) !== 'win') {
         $this->markTestSkipped('Unable to test windows specific paths on other OS.');
     }
     $error = array();
     $config_ary = array('path' => $path);
     validate_config_vars(array('path' => array('lang' => 'FOOBAR', 'validate' => $validation_type)), $config_ary, $error);
     if ($expected === true) {
         $this->assertEmpty($error);
     } else {
         $this->assertEquals(array($expected), $error);
     }
 }
开发者ID:MrAdder,项目名称:phpbb,代码行数:17,代码来源:validate_config_vars_test.php

示例13: main

    public function main($id, $mode)
    {
        $submit = isset($_POST['submit']) ? true : false;
        $form_key = 'acp_portal';
        add_form_key($form_key);
        /**
         *	Validation types are:
         *		string, int, bool,
         *		script_path (absolute path in url - beginning with / and no trailing slash),
         *		rpath (relative), rwpath (realtive, writeable), path (relative path, but able to escape the root), wpath (writeable)
         */
        switch ($mode) {
            case 'config':
                $display_vars = array('title' => 'ACP_PORTAL_GENERAL_TITLE', 'vars' => array('legend1' => 'ACP_PORTAL_CONFIG_INFO', 'board3_enable' => array('lang' => 'PORTAL_ENABLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'board3_left_column' => array('lang' => 'PORTAL_LEFT_COLUMN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'board3_right_column' => array('lang' => 'PORTAL_RIGHT_COLUMN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'board3_version_check' => array('lang' => 'PORTAL_VERSION_CHECK', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'board3_phpbb_menu' => array('lang' => 'PORTAL_PHPBB_MENU', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'board3_display_jumpbox' => array('lang' => 'PORTAL_DISPLAY_JUMPBOX', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'legend2' => 'ACP_PORTAL_COLUMN_WIDTH_SETTINGS', 'board3_left_column_width' => array('lang' => 'PORTAL_LEFT_COLUMN_WIDTH', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true), 'board3_right_column_width' => array('lang' => 'PORTAL_RIGHT_COLUMN_WIDTH', 'validate' => 'int', 'type' => 'text:3:3', 'explain' => true)));
                $module_id = request_var('module_id', 0);
                if ($module_id) {
                    $sql = 'SELECT *
						FROM ' . PORTAL_MODULES_TABLE . '
						WHERE module_id = ' . (int) $module_id;
                    $result = $this->db->sql_query_limit($sql, 1);
                    $module_data = $this->db->sql_fetchrow($result);
                    $this->db->sql_freeresult($result);
                    if ($module_data !== false) {
                        $class = 'portal_' . $module_data['module_classname'] . '_module';
                        if (!class_exists($class)) {
                            include $this->phpbb_root_path . 'portal/modules/portal_' . $module_data['module_classname'] . '.' . $this->php_ex;
                        }
                        if (!class_exists($class)) {
                            trigger_error('CLASS_NOT_FOUND', E_USER_ERROR);
                        }
                        $this->c_class = new $class();
                        if ($this->c_class->language) {
                            $this->user->add_lang('mods/portal/' . $this->c_class->language);
                        }
                        $module_name = $this->user->lang[$this->c_class->name];
                        $display_vars = $this->c_class->get_template_acp($module_id);
                        $this->template->assign_vars(array('MODULE_NAME' => isset($this->c_class->hide_name) && $this->c_class->hide_name == true ? '' : $module_data['module_name'], 'MODULE_IMAGE' => $module_data['module_image_src'], 'MODULE_IMAGE_WIDTH' => $module_data['module_image_width'], 'MODULE_IMAGE_HEIGHT' => $module_data['module_image_height'], 'MODULE_IMAGE_SRC' => $module_data['module_image_src'] ? $this->phpbb_root_path . 'styles/' . $this->user->theme['theme_path'] . '/theme/images/portal/' . $module_data['module_image_src'] : '', 'MODULE_ENABLED' => $module_data['module_status'] ? true : false, 'MODULE_SHOW_IMAGE' => in_array(column_num_string($module_data['module_column']), array('center', 'top', 'bottom')) ? false : true));
                        if ($module_data['module_classname'] != 'custom') {
                            $groups_ary = explode(',', $module_data['module_group_ids']);
                            // get group info from database and assign the block vars
                            $sql = 'SELECT group_id, group_name 
									FROM ' . GROUPS_TABLE . '
									ORDER BY group_id ASC';
                            $result = $this->db->sql_query($sql);
                            while ($row = $this->db->sql_fetchrow($result)) {
                                $this->template->assign_block_vars('permission_setting', array('SELECTED' => in_array($row['group_id'], $groups_ary) ? true : false, 'GROUP_NAME' => isset($this->user->lang['G_' . $row['group_name']]) ? $this->user->lang['G_' . $row['group_name']] : $row['group_name'], 'GROUP_ID' => $row['group_id']));
                            }
                            $this->db->sql_freeresult($result);
                        }
                        $this->template->assign_var('SHOW_MODULE_OPTIONS', true);
                    }
                } else {
                    // only show the mod version check if we are on the General Settings page
                    mod_version_check();
                }
                $this->new_config = $this->config;
                $cfg_array = isset($_REQUEST['config']) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config;
                $error = array();
                // We validate the complete config if whished
                validate_config_vars($display_vars['vars'], $cfg_array, $error);
                if ($submit && !check_form_key($form_key)) {
                    $error[] = $this->user->lang['FORM_INVALID'];
                }
                // Do not write values if there is an error
                if (sizeof($error)) {
                    $submit = false;
                }
                // Reset module
                $reset_module = request_var('module_reset', 0);
                if ($reset_module) {
                    $this->reset_module($id, $mode, $module_id, $module_data);
                }
                // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
                foreach ($display_vars['vars'] as $config_name => $null) {
                    if ($submit && (isset($null['type']) && $null['type'] == 'custom' || isset($null['submit_type']) && $null['submit_type'] == 'custom')) {
                        $func = array($this->c_class, $null['submit']);
                        if (method_exists($this->c_class, $null['submit'])) {
                            $args = $module_id != 0 ? array($config_name, $module_id) : $config_name;
                            call_user_func_array($func, $args);
                        } else {
                            $args = $module_id != 0 ? array($cfg_array[$config_name], $config_name, $module_id) : $config_name;
                            call_user_func_array($null['submit'], $args);
                        }
                    }
                    if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) {
                        continue;
                    }
                    if (isset($null['type']) && $null['type'] == 'custom') {
                        continue;
                    }
                    $this->new_config[$config_name] = $config_value = $cfg_array[$config_name];
                    if ($submit) {
                        set_config($config_name, $config_value);
                    }
                }
                if ($submit) {
                    $module_permission = request_var('permission-setting', array(0 => ''));
                    $groups_ary = array();
                    $img_error = '';
                    // get groups and check if the selected groups actually exist
//.........这里部分代码省略.........
开发者ID:gonzo1247,项目名称:hitman_roa,代码行数:101,代码来源:acp_portal.php

示例14: main

 function main($id, $mode)
 {
     global $db, $user, $auth, $template, $request, $phpbb_log;
     global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
     // Set up general vars
     $action = $request->variable('action', '');
     $submit = isset($_POST['submit']) ? true : false;
     $this->tpl_name = 'acp_hidebbcode';
     $form_key = 'acp_hidebbcode';
     add_form_key($form_key);
     switch ($mode) {
         case 'settings':
             $display_vars = array('title' => 'HIDEBB_SETTINGS', 'vars' => array('legend1' => 'GENERAL_SETTINGS', 'hidebbcode_unhide_reply' => array('lang' => 'HIDEBB_REPLY_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'hidebbcode_unhide_tfp' => array('lang' => 'HIDEBB_TFP_ENABLE', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'hidebbcode_hide_attach' => array('lang' => 'HIDEBB_HIDE_ATTACH', 'validate' => 'bool', 'type' => 'radio:enabled_disabled', 'explain' => true), 'legend2' => 'ACP_SUBMIT_CHANGES'));
             break;
         default:
             trigger_error('NO_MODE', E_USER_ERROR);
             break;
     }
     if (isset($display_vars['lang'])) {
         $user->add_lang($display_vars['lang']);
     }
     $this->new_config = $config;
     $cfg_array = isset($_REQUEST['config']) ? utf8_normalize_nfc($request->variable('config', array('' => ''), true)) : $this->new_config;
     $error = array();
     // We validate the complete config if whished
     validate_config_vars($display_vars['vars'], $cfg_array, $error);
     // Lets check if the path entered isn't valid and if we're gonna complain
     if ($submit && $mode == 'settings') {
         // Checks
     }
     if ($submit && !check_form_key($form_key)) {
         $error[] = $user->lang['FORM_INVALID'];
     }
     // Do not write values if there is an error
     if (sizeof($error)) {
         $submit = false;
     }
     // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
     foreach ($display_vars['vars'] as $config_name => $null) {
         if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) {
             continue;
         }
         $this->new_config[$config_name] = $config_value = $cfg_array[$config_name];
         if ($submit) {
             $config->set($config_name, $config_value);
         }
     }
     if (sizeof($error)) {
         $submit = false;
     }
     if ($submit) {
         $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_HIDEBBCODE');
         trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
     }
     $this->page_title = $display_vars['title'];
     $template->assign_vars(array('L_TITLE' => $user->lang[$display_vars['title']], 'L_TITLE_EXPLAIN' => $user->lang[$display_vars['title'] . '_EXPLAIN'], 'S_ERROR' => sizeof($error) ? true : false, 'ERROR_MSG' => implode('<br />', $error)));
     $template->assign_var('U_ACTION', $this->u_action);
     // Output relevant page set in $display_vars
     foreach ($display_vars['vars'] as $config_key => $vars) {
         if (!is_array($vars) && strpos($config_key, 'legend') === false) {
             continue;
         }
         if (strpos($config_key, 'legend') !== false) {
             $template->assign_block_vars('options', array('S_LEGEND' => true, 'LEGEND' => isset($user->lang[$vars]) ? $user->lang[$vars] : $vars));
             continue;
         }
         $type = explode(':', $vars['type']);
         $l_explain = '';
         if ($vars['explain'] && isset($vars['lang_explain'])) {
             $l_explain = isset($user->lang[$vars['lang_explain']]) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
         } else {
             if ($vars['explain']) {
                 $l_explain = isset($user->lang[$vars['lang'] . '_EXPLAIN']) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
             }
         }
         $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
         if (empty($content)) {
             continue;
         }
         $template->assign_block_vars('options', array('KEY' => $config_key, 'TITLE' => isset($user->lang[$vars['lang']]) ? $user->lang[$vars['lang']] : $vars['lang'], 'S_EXPLAIN' => $vars['explain'], 'TITLE_EXPLAIN' => $l_explain, 'CONTENT' => $content));
         unset($display_vars['vars'][$config_key]);
     }
 }
开发者ID:andares-phpBB-Es,项目名称:phpbb_hidebbcode,代码行数:83,代码来源:acp_hidebbcode_module.php

示例15: infraction_general

 public function infraction_general()
 {
     global $auth, $db, $user, $template;
     global $config, $phpbb_root_path, $phpEx, $phpbb_admin_path;
     $action = request_var('action', '');
     $submit = isset($_POST['submit']) || isset($_POST['allow_quick_reply_enable']) ? true : false;
     $form_key = 'acp_infractions';
     add_form_key($form_key);
     $display_vars = array('title' => 'ACP_INFRACTION_GENERAL', 'vars' => array('legend1' => 'ACP_INFRACTION_GENERAL', 'infractions_hard_delete' => array('lang' => 'INFRACTION_DELETE_TYPE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'infractions_deleted_keep_time' => array('lang' => 'INFRACTION_DELETE_KEEP_TIME', 'validate' => 'int', 'type' => 'text:40:40', 'explain' => true), 'infractions_pm_sig' => array('lang' => 'INFRACTION_PM_SIG', 'validate' => 'string', 'type' => 'textarea:4:40', 'explain' => true)));
     // ---------
     if (isset($display_vars['lang'])) {
         $user->add_lang($display_vars['lang']);
     }
     $this->new_config = $config;
     $cfg_array = isset($_REQUEST['config']) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config;
     $error = array();
     // We validate the complete config if whished
     validate_config_vars($display_vars['vars'], $cfg_array, $error);
     if ($submit && !check_form_key($form_key)) {
         $error[] = $user->lang['FORM_INVALID'];
     }
     // Do not write values if there is an error
     if (sizeof($error)) {
         $submit = false;
     }
     // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
     foreach ($display_vars['vars'] as $config_name => $null) {
         if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false) {
             continue;
         }
         if ($config_name == 'auth_method' || $config_name == 'feed_news_id' || $config_name == 'feed_exclude_id') {
             continue;
         }
         $this->new_config[$config_name] = $config_value = $cfg_array[$config_name];
         if ($config_name == 'email_function_name') {
             $this->new_config['email_function_name'] = trim(str_replace(array('(', ')'), array('', ''), $this->new_config['email_function_name']));
             $this->new_config['email_function_name'] = empty($this->new_config['email_function_name']) || !function_exists($this->new_config['email_function_name']) ? 'mail' : $this->new_config['email_function_name'];
             $config_value = $this->new_config['email_function_name'];
         }
         if ($submit) {
             set_config($config_name, $config_value);
             if ($config_name == 'allow_quick_reply' && isset($_POST['allow_quick_reply_enable'])) {
                 enable_bitfield_column_flag(FORUMS_TABLE, 'forum_flags', log(FORUM_FLAG_QUICK_REPLY, 2));
             }
         }
     }
     // Output relevant page
     foreach ($display_vars['vars'] as $config_key => $vars) {
         if (!is_array($vars) && strpos($config_key, 'legend') === false) {
             continue;
         }
         if (strpos($config_key, 'legend') !== false) {
             $template->assign_block_vars('options', array('S_LEGEND' => true, 'LEGEND' => isset($user->lang[$vars]) ? $user->lang[$vars] : $vars));
             continue;
         }
         $type = explode(':', $vars['type']);
         $l_explain = '';
         if ($vars['explain'] && isset($vars['lang_explain'])) {
             $l_explain = isset($user->lang[$vars['lang_explain']]) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
         } else {
             if ($vars['explain']) {
                 $l_explain = isset($user->lang[$vars['lang'] . '_EXPLAIN']) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
             }
         }
         $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars);
         if (empty($content)) {
             continue;
         }
         $template->assign_block_vars('options', array('KEY' => $config_key, 'TITLE' => isset($user->lang[$vars['lang']]) ? $user->lang[$vars['lang']] : $vars['lang'], 'S_EXPLAIN' => $vars['explain'], 'TITLE_EXPLAIN' => $l_explain, 'CONTENT' => $content));
         unset($display_vars['vars'][$config_key]);
     }
     if ($submit) {
         add_log('admin', 'INFRACTION_LOG_UPDATED');
         trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
     }
 }
开发者ID:Nelsaidi,项目名称:phpBB-Infractions,代码行数:76,代码来源:acp_infractions.php


注:本文中的validate_config_vars函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。