Ejemplo n.º 1
0
 public function display()
 {
     global $lang_common, $lang_admin_common;
     require FEATHER_ROOT . 'include/common_admin.php';
     if ($this->user->g_id != FEATHER_ADMIN) {
         message($lang_common['No permission'], '403');
     }
     define('FEATHER_ADMIN_CONSOLE', 1);
     // Load the admin_options.php language file
     require FEATHER_ROOT . 'lang/' . $admin_language . '/options.php';
     if ($this->feather->request->isPost()) {
         $this->model->update_options();
     }
     $page_title = array(feather_escape($this->config['o_board_title']), $lang_admin_common['Admin'], $lang_admin_common['Options']);
     define('FEATHER_ACTIVE_PAGE', 'admin');
     $this->header->setTitle($page_title)->display();
     generate_admin_menu('options');
     $this->feather->render('admin/options.php', array('lang_admin_options' => $lang_admin_options, 'feather_config' => $this->config, 'feather_user' => $this->user, 'languages' => forum_list_langs(), 'styles' => $this->model->get_styles(), 'times' => $this->model->get_times(), 'feather' => $this->feather));
     $this->footer->display();
 }
Ejemplo n.º 2
0
 public function display()
 {
     global $lang_common, $lang_antispam_questions, $lang_antispam, $lang_register, $lang_prof_reg;
     if (!$this->user->is_guest) {
         header('Location: ' . get_base_url());
         exit;
     }
     // Load the register.php language file
     require FEATHER_ROOT . 'lang/' . $this->user->language . '/register.php';
     // Load the register.php/profile.php language file
     require FEATHER_ROOT . 'lang/' . $this->user->language . '/prof_reg.php';
     // Antispam feature
     require FEATHER_ROOT . 'lang/' . $this->user->language . '/antispam.php';
     $index_questions = rand(0, count($lang_antispam_questions) - 1);
     // Display an error message if new registrations are disabled
     // If $_REQUEST['username'] or $_REQUEST['password'] are filled, we are facing a bot
     if ($this->config['o_regs_allow'] == '0' || $this->request->post('username') || $this->request->post('password')) {
         message($lang_register['No new regs']);
     }
     $page_title = array(feather_escape($this->config['o_board_title']), $lang_register['Register']);
     $required_fields = array('req_user' => $lang_common['Username'], 'req_password1' => $lang_common['Password'], 'req_password2' => $lang_prof_reg['Confirm pass'], 'req_email1' => $lang_common['Email'], 'req_email2' => $lang_common['Email'] . ' 2', 'captcha' => $lang_antispam['Robot title']);
     $focus_element = array('register', 'req_user');
     define('FEATHER_ACTIVE_PAGE', 'register');
     $user['timezone'] = isset($user['timezone']) ? $user['timezone'] : $this->config['o_default_timezone'];
     $user['dst'] = isset($user['dst']) ? $user['dst'] : $this->config['o_default_dst'];
     $user['email_setting'] = isset($user['email_setting']) ? $user['email_setting'] : $this->config['o_default_email_setting'];
     $user['errors'] = '';
     if ($this->feather->request()->isPost()) {
         $user = $this->model->check_for_errors();
         // Did everything go according to plan? Insert the user
         if (empty($user['errors'])) {
             $this->model->insert_user($user);
         }
     }
     $this->header->setTitle($page_title)->setFocusElement($focus_element)->setRequiredFields($required_fields)->display();
     $this->feather->render('register/form.php', array('errors' => $user['errors'], 'feather_config' => $this->config, 'lang_register' => $lang_register, 'lang_common' => $lang_common, 'lang_prof_reg' => $lang_prof_reg, 'lang_antispam' => $lang_antispam, 'lang_antispam_questions' => $lang_antispam_questions, 'index_questions' => $index_questions, 'feather' => $this->feather, 'languages' => forum_list_langs(), 'question' => array_keys($lang_antispam_questions), 'qencoded' => md5(array_keys($lang_antispam_questions)[$index_questions])));
     $this->footer->display();
 }
Ejemplo n.º 3
0
            echo "\t\t\t\t\t\t\t\t" . '<option value="' . $key . '"';
            if ($user['date_format'] == $key) {
                echo ' selected="selected"';
            }
            echo '>' . format_time(time(), true, $date_format, null, false, true);
            if ($key == 0) {
                echo ' (' . $lang_prof_reg['Default'] . ')';
            }
            echo "</option>\n";
        }
        ?>
							</select>
							<br /></label>

<?php 
        $languages = forum_list_langs();
        // Only display the language selection box if there's more than one language available
        if (count($languages) > 1) {
            ?>
							<label><?php 
            echo $lang_prof_reg['Language'];
            ?>
							<br /><select name="form[language]">
<?php 
            foreach ($languages as $temp) {
                if ($user['language'] == $temp) {
                    echo "\t\t\t\t\t\t\t\t" . '<option value="' . $temp . '" selected="selected">' . $temp . '</option>' . "\n";
                } else {
                    echo "\t\t\t\t\t\t\t\t" . '<option value="' . $temp . '">' . $temp . '</option>' . "\n";
                }
            }
Ejemplo n.º 4
0
 public static function validate_config($username, $password1, $password2, $email, $title, $default_lang, $default_style)
 {
     $alerts = array();
     // Validate username and passwords
     if (luna_strlen($username) < 2) {
         $alerts[] = __('Usernames must be at least 2 characters long.', 'luna');
     } elseif (luna_strlen($username) > 25) {
         // This usually doesn't happen since the form element only accepts 25 characters
         $alerts[] = __('Usernames must not be more than 25 characters long.', 'luna');
     } elseif (!strcasecmp($username, 'Guest')) {
         $alerts[] = __('The username guest is reserved.', 'luna');
     } elseif (preg_match('%[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}%', $username) || preg_match('%((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\\b((25[0-5])|(1\\d{2})|(2[0-4]\\d)|(\\d{1,2}))\\b)\\.){3}(\\b((25[0-5])|(1\\d{2})|(2[0-4]\\d)|(\\d{1,2}))\\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\\b((25[0-5])|(1\\d{2})|(2[0-4]\\d)|(\\d{1,2}))\\b)\\.){3}(\\b((25[0-5])|(1\\d{2})|(2[0-4]\\d)|(\\d{1,2}))\\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\\b((25[0-5])|(1\\d{2})|(2[0-4]\\d)|(\\d{1,2}))\\b)\\.){3}(\\b((25[0-5])|(1\\d{2})|(2[0-4]\\d)|(\\d{1,2}))\\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))%', $username)) {
         $alerts[] = __('Usernames may not be in the form of an IP address.', 'luna');
     } elseif ((strpos($username, '[') !== false || strpos($username, ']') !== false) && strpos($username, '\'') !== false && strpos($username, '"') !== false) {
         $alerts[] = __('Usernames may not contain all the characters \', " and [ or ] at once.', 'luna');
     } elseif (preg_match('%(?:\\[/?(?:b|u|i|h|colou?r|quote|code|img|url|email|list)\\]|\\[(?:code|quote|list)=)%i', $username)) {
         $alerts[] = __('Usernames may not contain any of the text formatting tags (BBCode) that the forum uses.', 'luna');
     }
     if (luna_strlen($password1) < 4) {
         $alerts[] = __('Passwords must be at least 6 characters long.', 'luna');
     } elseif ($password1 != $password2) {
         $alerts[] = __('Passwords do not match.', 'luna');
     }
     // Validate email
     require FORUM_ROOT . 'include/email.php';
     if (!is_valid_email($email)) {
         $alerts[] = __('The administrator email address you entered is invalid.', 'luna');
     }
     if ($title == '') {
         $alerts[] = __('You must enter a board title.', 'luna');
     }
     $languages = forum_list_langs();
     if (!in_array($default_lang, $languages)) {
         $alerts[] = __('The default language chosen doesn\'t seem to exist.', 'luna');
     }
     $styles = forum_list_styles();
     if (!in_array($default_style, $styles)) {
         $alerts[] = __('The default style chosen doesn\'t seem to exist.', 'luna');
     }
     return $alerts;
 }
Ejemplo n.º 5
0
            $mailer->send($email1, $mail_tpl['subject'], $mail_tpl['message']);
            message(sprintf($lang_register['Reg email'], $panther_config['o_admin_email']), true);
        }
        panther_setcookie($new_uid, $login_key, time() + $panther_config['o_timeout_visit']);
        redirect(panther_link($panther_url['index']), $lang_register['Reg complete']);
    }
}
$page_title = array($panther_config['o_board_title'], $lang_register['Register']);
$required_fields = array('req_user' => $lang_common['Username'], 'req_password1' => $lang_common['Password'], 'req_password2' => $lang_prof_reg['Confirm pass'], 'req_email1' => $lang_common['Email'], 'req_email2' => $lang_common['Email'] . ' 2');
$focus_element = array('register', 'req_user');
if (!empty($panther_robots)) {
    $required_fields['answer'] = $lang_common['Robot title'];
}
($hook = get_extensions('register_before_header')) ? eval($hook) : null;
define('PANTHER_ACTIVE_PAGE', 'register');
require PANTHER_ROOT . 'header.php';
$timezone = isset($timezone) ? $timezone : $panther_config['o_default_timezone'];
$dst = isset($dst) ? $dst : $panther_config['o_default_dst'];
$email_setting = isset($email_setting) ? $email_setting : $panther_config['o_default_email_setting'];
($hook = get_extensions('register_before_submit')) ? eval($hook) : null;
$render = array('lang_register' => $lang_register, 'errors' => $errors, 'form_action' => panther_link($panther_url['register_register']), 'csrf_token' => generate_csrf_token(), 'lang_common' => $lang_common, 'lang_prof_reg' => $lang_prof_reg, 'POST' => $_POST, 'panther_config' => $panther_config, 'dst' => $dst, 'timezone' => $timezone, 'email_setting' => $email_setting, 'languages' => forum_list_langs());
if (!empty($panther_robots)) {
    $id = array_rand($panther_robots);
    $test = $panther_robots[$id];
    $render['robot_id'] = $id;
    $render['robot_test'] = $test;
}
$tpl = load_template('register.tpl');
echo $tpl->render($render);
($hook = get_extensions('register_after_output')) ? eval($hook) : null;
require PANTHER_ROOT . 'footer.php';
Ejemplo n.º 6
0
     $ps = $db->select('warnings', 'SUM(points)', $data, 'user_id=:id AND (date_expire>:time OR date_expire=0)');
     $has_active = $ps->fetchColumn();
     $page_title = array($panther_config['o_board_title'], $lang_common['Profile'], $lang_profile['Section essentials']);
     $required_fields = array('req_username' => $lang_common['Username'], 'req_email' => $lang_common['Email']);
     define('PANTHER_ACTIVE_PAGE', 'profile');
     require PANTHER_ROOT . 'header.php';
     generate_profile_menu('essentials');
     $time_formats = $date_formats = array();
     foreach (array_unique($forum_time_formats) as $key => $time_format) {
         $time_formats[] = array('value' => $key, 'time' => format_time(time(), false, null, $time_format, true, true) . ($key == 0 ? ' (' . $lang_prof_reg['Default'] . ')' : ''));
     }
     foreach (array_unique($forum_date_formats) as $key => $date_format) {
         $date_formats[] = array('value' => $key, 'time' => format_time(time(), true, $date_format, null, false, true) . ($key == 0 ? ' (' . $lang_prof_reg['Default'] . ')' : ''));
     }
     $tpl = load_template('profile_essentials.tpl');
     echo $tpl->render(array('id' => $id, 'lang_profile' => $lang_profile, 'lang_common' => $lang_common, 'lang_prof_reg' => $lang_prof_reg, 'panther_user' => $panther_user, 'user' => $user, 'csrf_token' => generate_csrf_token(), 'form_action' => panther_link($panther_url['profile_essentials'], array($id)), 'panther_config' => $panther_config, 'posts_actions' => $posts_actions, 'time_formats' => $time_formats, 'date_formats' => $date_formats, 'languages' => forum_list_langs(), 'change_pass_link' => panther_link($panther_url['change_password'], array($id)), 'last_visit' => format_time($user['last_visit']), 'last_post' => format_time($user['last_post']), 'registered' => format_time($user['registered'], true), 'ip_link' => panther_link($panther_url['get_host'], array($user['registration_ip'])), 'warning_link' => panther_link($panther_url['warning_view'], array($id)), 'warn_link' => panther_link($panther_url['warn_user'], array($id)), 'has_active' => $has_active, 'lang_warnings' => $lang_warnings, 'posts' => forum_number_format($user['num_posts']), 'email_link' => $email_link));
 } else {
     if ($section == 'personal') {
         $page_title = array($panther_config['o_board_title'], $lang_common['Profile'], $lang_profile['Section personal']);
         define('PANTHER_ACTIVE_PAGE', 'profile');
         require PANTHER_ROOT . 'header.php';
         generate_profile_menu('personal');
         $tpl = load_template('profile_personal.tpl');
         echo $tpl->render(array('user' => $user, 'lang_profile' => $lang_profile, 'csrf_token' => generate_csrf_token(), 'form_action' => panther_link($panther_url['profile_personal'], array($id)), 'panther_user' => $panther_user, 'user' => $user, 'lang_common' => $lang_common));
     } else {
         if ($section == 'messaging') {
             $page_title = array($panther_config['o_board_title'], $lang_common['Profile'], $lang_profile['Section messaging']);
             define('PANTHER_ACTIVE_PAGE', 'profile');
             require PANTHER_ROOT . 'header.php';
             generate_profile_menu('messaging');
             $tpl = load_template('profile_messaging.tpl');
Ejemplo n.º 7
0
 public function update_options()
 {
     global $lang_admin_options, $lang_common;
     $form = array('board_title' => feather_trim($this->request->post('form_board_title')), 'board_desc' => feather_trim($this->request->post('form_board_desc')), 'base_url' => feather_trim($this->request->post('form_base_url')), 'default_timezone' => floatval($this->request->post('form_default_timezone')), 'default_dst' => $this->request->post('form_default_dst') != '1' ? '0' : '1', 'default_lang' => feather_trim($this->request->post('form_default_lang')), 'default_style' => feather_trim($this->request->post('form_default_style')), 'time_format' => feather_trim($this->request->post('form_time_format')), 'date_format' => feather_trim($this->request->post('form_date_format')), 'timeout_visit' => intval($this->request->post('form_timeout_visit')) > 0 ? intval($this->request->post('form_timeout_visit')) : 1, 'timeout_online' => intval($this->request->post('form_timeout_online')) > 0 ? intval($this->request->post('form_timeout_online')) : 1, 'redirect_delay' => intval($this->request->post('form_redirect_delay')) >= 0 ? intval($this->request->post('form_redirect_delay')) : 0, 'show_version' => $this->request->post('form_show_version') != '1' ? '0' : '1', 'show_user_info' => $this->request->post('form_show_user_info') != '1' ? '0' : '1', 'show_post_count' => $this->request->post('form_show_post_count') != '1' ? '0' : '1', 'smilies' => $this->request->post('form_smilies') != '1' ? '0' : '1', 'smilies_sig' => $this->request->post('form_smilies_sig') != '1' ? '0' : '1', 'make_links' => $this->request->post('form_make_links') != '1' ? '0' : '1', 'topic_review' => intval($this->request->post('form_topic_review')) >= 0 ? intval($this->request->post('form_topic_review')) : 0, 'disp_topics_default' => intval($this->request->post('form_disp_topics_default')), 'disp_posts_default' => intval($this->request->post('form_disp_posts_default')), 'indent_num_spaces' => intval($this->request->post('form_indent_num_spaces')) >= 0 ? intval($this->request->post('form_indent_num_spaces')) : 0, 'quote_depth' => intval($this->request->post('form_quote_depth')) > 0 ? intval($this->request->post('form_quote_depth')) : 1, 'quickpost' => $this->request->post('form_quickpost') != '1' ? '0' : '1', 'users_online' => $this->request->post('form_users_online') != '1' ? '0' : '1', 'censoring' => $this->request->post('form_censoring') != '1' ? '0' : '1', 'signatures' => $this->request->post('form_signatures') != '1' ? '0' : '1', 'show_dot' => $this->request->post('form_show_dot') != '1' ? '0' : '1', 'topic_views' => $this->request->post('form_topic_views') != '1' ? '0' : '1', 'quickjump' => $this->request->post('form_quickjump') != '1' ? '0' : '1', 'gzip' => $this->request->post('form_gzip') != '1' ? '0' : '1', 'search_all_forums' => $this->request->post('form_search_all_forums') != '1' ? '0' : '1', 'additional_navlinks' => feather_trim($this->request->post('form_additional_navlinks')), 'feed_type' => intval($this->request->post('form_feed_type')), 'feed_ttl' => intval($this->request->post('form_feed_ttl')), 'report_method' => intval($this->request->post('form_report_method')), 'mailing_list' => feather_trim($this->request->post('form_mailing_list')), 'avatars' => $this->request->post('form_avatars') != '1' ? '0' : '1', 'avatars_dir' => feather_trim($this->request->post('form_avatars_dir')), 'avatars_width' => intval($this->request->post('form_avatars_width')) > 0 ? intval($this->request->post('form_avatars_width')) : 1, 'avatars_height' => intval($this->request->post('form_avatars_height')) > 0 ? intval($this->request->post('form_avatars_height')) : 1, 'avatars_size' => intval($this->request->post('form_avatars_size')) > 0 ? intval($this->request->post('form_avatars_size')) : 1, 'admin_email' => strtolower(feather_trim($this->request->post('form_admin_email'))), 'webmaster_email' => strtolower(feather_trim($this->request->post('form_webmaster_email'))), 'forum_subscriptions' => $this->request->post('form_forum_subscriptions') != '1' ? '0' : '1', 'topic_subscriptions' => $this->request->post('form_topic_subscriptions') != '1' ? '0' : '1', 'smtp_host' => feather_trim($this->request->post('form_smtp_host')), 'smtp_user' => feather_trim($this->request->post('form_smtp_user')), 'smtp_ssl' => $this->request->post('form_smtp_ssl') != '1' ? '0' : '1', 'regs_allow' => $this->request->post('form_regs_allow') != '1' ? '0' : '1', 'regs_verify' => $this->request->post('form_regs_verify') != '1' ? '0' : '1', 'regs_report' => $this->request->post('form_regs_report') != '1' ? '0' : '1', 'rules' => $this->request->post('form_rules') != '1' ? '0' : '1', 'rules_message' => feather_trim($this->request->post('form_rules_message')), 'default_email_setting' => intval($this->request->post('form_default_email_setting')), 'announcement' => $this->request->post('form_announcement') != '1' ? '0' : '1', 'announcement_message' => feather_trim($this->request->post('form_announcement_message')), 'maintenance' => $this->request->post('form_maintenance') != '1' ? '0' : '1', 'maintenance_message' => feather_trim($this->request->post('form_maintenance_message')));
     if ($form['board_title'] == '') {
         message($lang_admin_options['Must enter title message']);
     }
     // Make sure base_url doesn't end with a slash
     if (substr($form['base_url'], -1) == '/') {
         $form['base_url'] = substr($form['base_url'], 0, -1);
     }
     // Convert IDN to Punycode if needed
     if (preg_match('/[^\\x00-\\x7F]/', $form['base_url'])) {
         if (!function_exists('idn_to_ascii')) {
             message($lang_admin_options['Base URL problem']);
         } else {
             $form['base_url'] = idn_to_ascii($form['base_url']);
         }
     }
     $languages = forum_list_langs();
     if (!in_array($form['default_lang'], $languages)) {
         message($lang_common['Bad request'], '404');
     }
     $styles = forum_list_styles();
     if (!in_array($form['default_style'], $styles)) {
         message($lang_common['Bad request'], '404');
     }
     if ($form['time_format'] == '') {
         $form['time_format'] = 'H:i:s';
     }
     if ($form['date_format'] == '') {
         $form['date_format'] = 'Y-m-d';
     }
     require FEATHER_ROOT . 'include/email.php';
     if (!is_valid_email($form['admin_email'])) {
         message($lang_admin_options['Invalid e-mail message']);
     }
     if (!is_valid_email($form['webmaster_email'])) {
         message($lang_admin_options['Invalid webmaster e-mail message']);
     }
     if ($form['mailing_list'] != '') {
         $form['mailing_list'] = strtolower(preg_replace('%\\s%S', '', $form['mailing_list']));
     }
     // Make sure avatars_dir doesn't end with a slash
     if (substr($form['avatars_dir'], -1) == '/') {
         $form['avatars_dir'] = substr($form['avatars_dir'], 0, -1);
     }
     if ($form['additional_navlinks'] != '') {
         $form['additional_navlinks'] = feather_trim(feather_linebreaks($form['additional_navlinks']));
     }
     // Change or enter a SMTP password
     if ($this->request->post('form_smtp_change_pass')) {
         $smtp_pass1 = $this->request->post('form_smtp_pass1') ? feather_trim($this->request->post('form_smtp_pass1')) : '';
         $smtp_pass2 = $this->request->post('form_smtp_pass2') ? feather_trim($this->request->post('form_smtp_pass2')) : '';
         if ($smtp_pass1 == $smtp_pass2) {
             $form['smtp_pass'] = $smtp_pass1;
         } else {
             message($lang_admin_options['SMTP passwords did not match']);
         }
     }
     if ($form['announcement_message'] != '') {
         $form['announcement_message'] = feather_linebreaks($form['announcement_message']);
     } else {
         $form['announcement_message'] = $lang_admin_options['Enter announcement here'];
         $form['announcement'] = '0';
     }
     if ($form['rules_message'] != '') {
         $form['rules_message'] = feather_linebreaks($form['rules_message']);
     } else {
         $form['rules_message'] = $lang_admin_options['Enter rules here'];
         $form['rules'] = '0';
     }
     if ($form['maintenance_message'] != '') {
         $form['maintenance_message'] = feather_linebreaks($form['maintenance_message']);
     } else {
         $form['maintenance_message'] = $lang_admin_options['Default maintenance message'];
         $form['maintenance'] = '0';
     }
     // Make sure the number of displayed topics and posts is between 3 and 75
     if ($form['disp_topics_default'] < 3) {
         $form['disp_topics_default'] = 3;
     } elseif ($form['disp_topics_default'] > 75) {
         $form['disp_topics_default'] = 75;
     }
     if ($form['disp_posts_default'] < 3) {
         $form['disp_posts_default'] = 3;
     } elseif ($form['disp_posts_default'] > 75) {
         $form['disp_posts_default'] = 75;
     }
     if ($form['feed_type'] < 0 || $form['feed_type'] > 2) {
         message($lang_common['Bad request'], '404');
     }
     if ($form['feed_ttl'] < 0) {
         message($lang_common['Bad request'], '404');
     }
     if ($form['report_method'] < 0 || $form['report_method'] > 2) {
         message($lang_common['Bad request'], '404');
     }
     if ($form['default_email_setting'] < 0 || $form['default_email_setting'] > 2) {
         message($lang_common['Bad request'], '404');
     }
     if ($form['timeout_online'] >= $form['timeout_visit']) {
         message($lang_admin_options['Timeout error message']);
     }
     foreach ($form as $key => $input) {
         // Only update values that have changed
         if (array_key_exists('o_' . $key, $this->config) && $this->config['o_' . $key] != $input) {
             if ($input != '' || is_int($input)) {
                 DB::for_table('config')->where('conf_name', 'o_' . $key)->update_many('conf_value', $input);
             } else {
                 DB::for_table('config')->where('conf_name', 'o_' . $key)->update_many_expr('conf_value', 'NULL');
             }
         }
     }
     // Regenerate the config cache
     if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) {
         require FEATHER_ROOT . 'include/cache.php';
     }
     generate_config_cache();
     clear_feed_cache();
     redirect(get_link('admin/options/'), $lang_admin_options['Options updated redirect']);
 }
Ejemplo n.º 8
0
    // Regenerate the config cache
    if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) {
        require PANTHER_ROOT . 'include/cache.php';
    }
    generate_config_cache();
    clear_feed_cache();
    if ($form['url_type'] != $panther_config['o_url_type']) {
        //Load new URL pack to avoid 404 error after redirecting
        if (file_exists(PANTHER_ROOT . 'include/url/' . $form['url_type'] . '.php')) {
            require PANTHER_ROOT . 'include/url/' . $form['url_type'] . '.php';
        } else {
            require PANTHER_ROOT . 'include/url/default.php';
        }
        generate_quickjump_cache();
    }
    redirect(panther_link($panther_url['admin_options']), $lang_admin_options['Options updated redirect']);
}
$page_title = array($panther_config['o_board_title'], $lang_admin_common['Admin'], $lang_admin_common['Options']);
define('PANTHER_ACTIVE_PAGE', 'admin');
require PANTHER_ROOT . 'header.php';
generate_admin_menu('options');
$diff = ($panther_user['timezone'] + $panther_user['dst']) * 3600;
$timestamp = time() + $diff;
$schemes = get_url_schemes();
$scheme_options = array();
foreach ($schemes as $scheme) {
    $scheme_options[] = array('file' => $scheme, 'title' => substr(ucwords(str_replace('_', ' ', $scheme)), 0, -4));
}
$tpl = load_template('admin_options.tpl');
echo $tpl->render(array('lang_admin_options' => $lang_admin_options, 'lang_admin_common' => $lang_admin_common, 'panther_config' => $panther_config, 'form_action' => panther_link($panther_url['admin_options']), 'csrf_token' => generate_csrf_token(PANTHER_ADMIN_DIR . '/options.php'), 'max_file_size' => $max_file_size, 'types' => $scheme_options, 'languages' => forum_list_langs(), 'styles' => forum_list_styles(), 'time_format' => gmdate($panther_config['o_time_format'], $timestamp), 'date_format' => gmdate($panther_config['o_date_format'], $timestamp), 'censoring_link' => panther_link($panther_url['admin_censoring']), 'archive_link' => panther_link($panther_url['admin_archive']), 'ranks_link' => panther_link($panther_url['admin_ranks']), 'tasks_link' => panther_link($panther_url['admin_tasks']), 'feeds' => array(5, 15, 30, 60), 'smtp_pass' => !empty($panther_config['o_smtp_pass']) ? random_key(panther_strlen($panther_config['o_smtp_pass']), true) : '', 'themes' => forum_list_themes()));
require PANTHER_ROOT . 'footer.php';
Ejemplo n.º 9
0
 public function update_profile($id, $info, $section)
 {
     global $lang_common, $lang_profile, $lang_prof_reg, $pd;
     $username_updated = false;
     // Validate input depending on section
     switch ($section) {
         case 'essentials':
             $form = array('timezone' => floatval($this->request->post('form_timezone')), 'dst' => $this->request->post('form_dst') ? '1' : '0', 'time_format' => intval($this->request->post('form_time_format')), 'date_format' => intval($this->request->post('form_date_format')));
             // Make sure we got a valid language string
             if ($this->request->post('form_language')) {
                 $languages = forum_list_langs();
                 $form['language'] = feather_trim($this->request->post('form_language'));
                 if (!in_array($form['language'], $languages)) {
                     message($lang_common['Bad request'], '404');
                 }
             }
             if ($this->user->is_admmod) {
                 $form['admin_note'] = feather_trim($this->request->post('admin_note'));
                 // Are we allowed to change usernames?
                 if ($this->user->g_id == FEATHER_ADMIN || $this->user->g_moderator == '1' && $this->user->g_mod_rename_users == '1') {
                     $form['username'] = feather_trim($this->request->post('req_username'));
                     if ($form['username'] != $info['old_username']) {
                         // Check username
                         require FEATHER_ROOT . 'lang/' . $this->user->language . '/register.php';
                         $errors = '';
                         $errors = check_username($form['username'], $errors, $id);
                         if (!empty($errors)) {
                             message($errors[0]);
                         }
                         $username_updated = true;
                     }
                 }
                 // We only allow administrators to update the post count
                 if ($this->user->g_id == FEATHER_ADMIN) {
                     $form['num_posts'] = intval($this->request->post('num_posts'));
                 }
             }
             if ($this->config['o_regs_verify'] == '0' || $this->user->is_admmod) {
                 require FEATHER_ROOT . 'include/email.php';
                 // Validate the email address
                 $form['email'] = strtolower(feather_trim($this->request->post('req_email')));
                 if (!is_valid_email($form['email'])) {
                     message($lang_common['Invalid email']);
                 }
             }
             break;
         case 'personal':
             $form = array('realname' => $this->request->post('form_realname') ? feather_trim($this->request->post('form_realname')) : '', 'url' => $this->request->post('form_url') ? feather_trim($this->request->post('form_url')) : '', 'location' => $this->request->post('form_location') ? feather_trim($this->request->post('form_location')) : '');
             // Add http:// if the URL doesn't contain it already (while allowing https://, too)
             if ($this->user->g_post_links == '1') {
                 if ($form['url'] != '') {
                     $url = url_valid($form['url']);
                     if ($url === false) {
                         message($lang_profile['Invalid website URL']);
                     }
                     $form['url'] = $url['url'];
                 }
             } else {
                 if (!empty($form['url'])) {
                     message($lang_profile['Website not allowed']);
                 }
                 $form['url'] = '';
             }
             if ($this->user->g_id == FEATHER_ADMIN) {
                 $form['title'] = feather_trim($this->request->post('title'));
             } elseif ($this->user->g_set_title == '1') {
                 $form['title'] = feather_trim($this->request->post('title'));
                 if ($form['title'] != '') {
                     // A list of words that the title may not contain
                     // If the language is English, there will be some duplicates, but it's not the end of the world
                     $forbidden = array('member', 'moderator', 'administrator', 'banned', 'guest', utf8_strtolower($lang_common['Member']), utf8_strtolower($lang_common['Moderator']), utf8_strtolower($lang_common['Administrator']), utf8_strtolower($lang_common['Banned']), utf8_strtolower($lang_common['Guest']));
                     if (in_array(utf8_strtolower($form['title']), $forbidden)) {
                         message($lang_profile['Forbidden title']);
                     }
                 }
             }
             break;
         case 'messaging':
             $form = array('jabber' => feather_trim($this->request->post('form_jabber')), 'icq' => feather_trim($this->request->post('form_icq')), 'msn' => feather_trim($this->request->post('form_msn')), 'aim' => feather_trim($this->request->post('form_aim')), 'yahoo' => feather_trim($this->request->post('form_yahoo')));
             // If the ICQ UIN contains anything other than digits it's invalid
             if (preg_match('%[^0-9]%', $form['icq'])) {
                 message($lang_prof_reg['Bad ICQ']);
             }
             break;
         case 'personality':
             $form = array();
             // Clean up signature from POST
             if ($this->config['o_signatures'] == '1') {
                 $form['signature'] = feather_linebreaks(feather_trim($this->request->post('signature')));
                 // Validate signature
                 if (feather_strlen($form['signature']) > $this->config['p_sig_length']) {
                     message(sprintf($lang_prof_reg['Sig too long'], $this->config['p_sig_length'], feather_strlen($form['signature']) - $this->config['p_sig_length']));
                 } elseif (substr_count($form['signature'], "\n") > $this->config['p_sig_lines'] - 1) {
                     message(sprintf($lang_prof_reg['Sig too many lines'], $this->config['p_sig_lines']));
                 } elseif ($form['signature'] && $this->config['p_sig_all_caps'] == '0' && is_all_uppercase($form['signature']) && !$this->user->is_admmod) {
                     $form['signature'] = utf8_ucwords(utf8_strtolower($form['signature']));
                 }
                 // Validate BBCode syntax
                 if ($this->config['p_sig_bbcode'] == '1') {
                     require FEATHER_ROOT . 'include/parser.php';
                     $errors = array();
                     $form['signature'] = preparse_bbcode($form['signature'], $errors, true);
                     if (count($errors) > 0) {
                         message('<ul><li>' . implode('</li><li>', $errors) . '</li></ul>');
                     }
                 }
             }
             break;
         case 'display':
             $form = array('disp_topics' => feather_trim($this->request->post('form_disp_topics')), 'disp_posts' => feather_trim($this->request->post('form_disp_posts')), 'show_smilies' => $this->request->post('form_show_smilies') ? '1' : '0', 'show_img' => $this->request->post('form_show_img') ? '1' : '0', 'show_img_sig' => $this->request->post('form_show_img_sig') ? '1' : '0', 'show_avatars' => $this->request->post('form_show_avatars') ? '1' : '0', 'show_sig' => $this->request->post('form_show_sig') ? '1' : '0');
             if ($form['disp_topics'] != '') {
                 $form['disp_topics'] = intval($form['disp_topics']);
                 if ($form['disp_topics'] < 3) {
                     $form['disp_topics'] = 3;
                 } elseif ($form['disp_topics'] > 75) {
                     $form['disp_topics'] = 75;
                 }
             }
             if ($form['disp_posts'] != '') {
                 $form['disp_posts'] = intval($form['disp_posts']);
                 if ($form['disp_posts'] < 3) {
                     $form['disp_posts'] = 3;
                 } elseif ($form['disp_posts'] > 75) {
                     $form['disp_posts'] = 75;
                 }
             }
             // Make sure we got a valid style string
             if ($this->request->post('form_style')) {
                 $styles = forum_list_styles();
                 $form['style'] = feather_trim($this->request->post('form_style'));
                 if (!in_array($form['style'], $styles)) {
                     message($lang_common['Bad request'], '404');
                 }
             }
             break;
         case 'privacy':
             $form = array('email_setting' => intval($this->request->post('form_email_setting')), 'notify_with_post' => $this->request->post('form_notify_with_post') ? '1' : '0', 'auto_notify' => $this->request->post('form_auto_notify') ? '1' : '0');
             if ($form['email_setting'] < 0 || $form['email_setting'] > 2) {
                 $form['email_setting'] = $this->config['o_default_email_setting'];
             }
             break;
         default:
             message($lang_common['Bad request'], '404');
     }
     // Single quotes around non-empty values and nothing for empty values
     $temp = array();
     foreach ($form as $key => $input) {
         $temp[$key] = $input;
     }
     if (empty($temp)) {
         message($lang_common['Bad request'], '404');
     }
     DB::for_table('users')->where('id', $id)->find_one()->set($temp)->save();
     // If we changed the username we have to update some stuff
     if ($username_updated) {
         $bans_updated = DB::for_table('bans')->where('username', $info['old_username'])->update_many('username', $form['username']);
         DB::for_table('posts')->where('poster_id', $id)->update_many('poster', $form['username']);
         DB::for_table('posts')->where('edited_by', $info['old_username'])->update_many('edited_by', $form['username']);
         DB::for_table('topics')->where('poster', $info['old_username'])->update_many('poster', $form['username']);
         DB::for_table('topics')->where('last_poster', $info['old_username'])->update_many('last_poster', $form['username']);
         DB::for_table('forums')->where('last_poster', $info['old_username'])->update_many('last_poster', $form['username']);
         DB::for_table('online')->where('ident', $info['old_username'])->update_many('ident', $form['username']);
         // If the user is a moderator or an administrator we have to update the moderator lists
         $group_id = DB::for_table('users')->where('id', $id)->find_one_col('group_id');
         $group_mod = DB::for_table('groups')->where('g_id', $group_id)->find_one_col('g_moderator');
         if ($group_id == FEATHER_ADMIN || $group_mod == '1') {
             $select_mods = array('id', 'moderators');
             $result = DB::for_table('forums')->select_many($select_mods)->find_many();
             foreach ($result as $cur_forum) {
                 $cur_moderators = $cur_forum['moderators'] != '' ? unserialize($cur_forum['moderators']) : array();
                 if (in_array($id, $cur_moderators)) {
                     unset($cur_moderators[$info['old_username']]);
                     $cur_moderators[$form['username']] = $id;
                     uksort($cur_moderators, 'utf8_strcasecmp');
                     DB::for_table('forums')->where('id', $cur_forum['id'])->find_one()->set('moderators', serialize($cur_moderators))->save();
                 }
             }
         }
         // Regenerate the users info cache
         if (!defined('FORUM_CACHE_FUNCTIONS_LOADED')) {
             require FEATHER_ROOT . 'include/cache.php';
         }
         generate_users_info_cache();
         // Check if the bans table was updated and regenerate the bans cache when needed
         if ($bans_updated) {
             generate_bans_cache();
         }
     }
     redirect(get_link('user/' . $id . '/section/' . $section . '/'), $lang_profile['Profile redirect']);
 }