1 | <?php |
2 | /** |
3 | * Options Management Administration Panel. |
4 | * |
5 | * If accessed directly in a browser this page shows a list of all saved options |
6 | * along with editable fields for their values. Serialized data is not supported |
7 | * and there is no way to remove options via this page. It is not linked to from |
8 | * anywhere else in the admin. |
9 | * |
10 | * This file is also the target of the forms in core and custom options pages |
11 | * that use the Settings API. In this case it saves the new option values |
12 | * and returns the user to their page of origin. |
13 | * |
14 | * @package WordPress |
15 | * @subpackage Administration |
16 | */ |
17 | |
18 | /** WordPress Administration Bootstrap */ |
19 | require_once('./admin.php'); |
20 | |
21 | $title = __('Settings'); |
22 | $this_file = 'options.php'; |
23 | $parent_file = 'options-general.php'; |
24 | |
25 | wp_reset_vars(array('action', 'option_page')); |
26 | |
27 | if ( empty($option_page) ) // This is for back compat and will eventually be removed. |
28 | $option_page = 'options'; |
29 | |
30 | if ( !current_user_can('manage_options') ) |
31 | wp_die(__('Cheatin’ uh?')); |
32 | |
33 | // Handle admin email change requests |
34 | if ( is_multisite() ) { |
35 | if ( ! empty($_GET[ 'adminhash' ] ) ) { |
36 | $new_admin_details = get_option( 'adminhash' ); |
37 | $redirect = 'options-general.php?updated=false'; |
38 | if ( is_array( $new_admin_details ) && $new_admin_details[ 'hash' ] == $_GET[ 'adminhash' ] && !empty($new_admin_details[ 'newemail' ]) ) { |
39 | update_option( 'admin_email', $new_admin_details[ 'newemail' ] ); | //Connection Handling
|
40 | delete_option( 'adminhash' ); |
41 | delete_option( 'new_admin_email' ); |
42 | $redirect = 'options-general.php?updated=true'; |
43 | } |
44 | wp_redirect( admin_url( $redirect ) ); |
45 | exit; |
46 | } elseif ( ! empty( $_GET['dismiss'] ) && 'new_admin_email' == $_GET['dismiss'] ) { |
47 | delete_option( 'adminhash' ); |
48 | delete_option( 'new_admin_email' ); |
49 | wp_redirect( admin_url( 'options-general.php?updated=true' ) ); |
50 | exit; |
51 | } |
52 | } |
53 | |
54 | if ( is_multisite() && !is_super_admin() && 'update' != $action ) |
55 | wp_die(__('Cheatin’ uh?')); |
56 | |
57 | $whitelist_options = array( |
58 | 'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string' ), |
59 | 'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ), |
60 | 'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type', 'embed_autourls', 'embed_size_w', 'embed_size_h' ), |
61 | 'privacy' => array( 'blog_public' ), |
62 | 'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'blog_charset', 'show_on_front', 'page_on_front', 'page_for_posts' ), |
63 | 'writing' => array( 'default_post_edit_rows', 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'enable_app', 'enable_xmlrpc' ), |
64 | 'options' => array( '' ) ); |
65 | |
66 | $mail_options = array('mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass'); |
67 | $uploads_options = array('uploads_use_yearmonth_folders', 'upload_path', 'upload_url_path'); |
68 | |
69 | if ( !is_multisite() ) { |
70 | if ( !defined( 'WP_SITEURL' ) ) |
71 | $whitelist_options['general'][] = 'siteurl'; |
72 | if ( !defined( 'WP_HOME' ) ) |
73 | $whitelist_options['general'][] = 'home'; |
74 | |
75 | $whitelist_options['general'][] = 'admin_email'; |
76 | $whitelist_options['general'][] = 'users_can_register'; |
77 | $whitelist_options['general'][] = 'default_role'; |
78 | |
79 | $whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options); |
80 | $whitelist_options['writing'][] = 'ping_sites'; |
81 | |
82 | $whitelist_options['media'] = array_merge($whitelist_options['media'], $uploads_options); |
83 | } else { |
84 | $whitelist_options['general'][] = 'new_admin_email'; |
85 | $whitelist_options['general'][] = 'WPLANG'; |
86 | $whitelist_options['general'][] = 'language'; |
87 | |
88 | if ( apply_filters( 'enable_post_by_email_configuration', true ) ) |
89 | $whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options); |
90 | |
91 | $whitelist_options[ 'misc' ] = array(); |
92 | } |
93 | |
94 | $whitelist_options = apply_filters( 'whitelist_options', $whitelist_options ); |
95 | |
96 | /* |
97 | * If $_GET['action'] == 'update' we are saving settings sent from a settings page |
98 | */ |
99 | if ( 'update' == $action ) { |
100 | if ( 'options' == $option_page && !isset( $_POST['option_page'] ) ) { // This is for back compat and will eventually be removed. |
101 | $unregistered = true; |
102 | check_admin_referer( 'update-options' ); |
103 | } else { |
104 | $unregistered = false; |
105 | check_admin_referer( $option_page . '-options' ); |
106 | } |
107 | |
108 | if ( !isset( $whitelist_options[ $option_page ] ) ) |
109 | wp_die( __( 'Error: options page not found.' ) ); |
110 | |
111 | if ( 'options' == $option_page ) { |
112 | if ( is_multisite() && ! is_super_admin() ) |
113 | wp_die( __( 'You do not have sufficient permissions to modify unregistered settings for this site.' ) ); |
114 | $options = explode( ',', stripslashes( $_POST[ 'page_options' ] ) ); |
115 | } else { |
116 | $options = $whitelist_options[ $option_page ]; |
117 | } |
118 | |
119 | // Handle custom date/time formats |
120 | if ( 'general' == $option_page ) { |
121 | if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['date_format'] ) ) |
122 | $_POST['date_format'] = $_POST['date_format_custom']; |
123 | if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['time_format'] ) ) |
124 | $_POST['time_format'] = $_POST['time_format_custom']; |
125 | // Map UTC+- timezones to gmt_offsets and set timezone_string to empty. |
126 | if ( !empty($_POST['timezone_string']) && preg_match('/^UTC[+-]/', $_POST['timezone_string']) ) { |
127 | $_POST['gmt_offset'] = $_POST['timezone_string']; |
128 | $_POST['gmt_offset'] = preg_replace('/UTC\+?/', '', $_POST['gmt_offset']); |
129 | $_POST['timezone_string'] = ''; |
130 | } |
131 | } |
132 | |
133 | if ( $options ) { |
134 | foreach ( $options as $option ) { |
135 | if ( $unregistered ) |
136 | _deprecated_argument( 'options.php', '2.7', sprintf( __( 'The <code>%1$s</code> setting is unregistered. Unregistered settings are deprecated. See http://codex.wordpress.org/Settings_API' ), $option, $option_page ) ); |
137 | |
138 | $option = trim($option); |
139 | $value = null; |
140 | if ( isset($_POST[$option]) ) |
141 | $value = $_POST[$option]; |
142 | if ( !is_array($value) ) |
143 | $value = trim($value); |
144 | $value = stripslashes_deep($value); |
145 | update_option($option, $value); |
146 | } |
147 | } |
148 | |
149 | /** |
150 | * Handle settings errors and return to options page |
151 | */ |
152 | // If no settings errors were registered add a general 'updated' message. |
153 | if ( !count( get_settings_errors() ) ) |
154 | add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated'); |
155 | set_transient('settings_errors', get_settings_errors(), 30); |
156 | |
157 | /** |
158 | * Redirect back to the settings page that was submitted |
159 | */ |
160 | $goback = add_query_arg( 'updated', 'true', wp_get_referer() ); |
161 | wp_redirect( $goback ); |
162 | exit; |
163 | } |
164 | |
165 | include('./admin-header.php'); ?> |
166 | |
167 | <div class="wrap"> |
168 | <?php screen_icon(); ?> |
169 | <h2><?php esc_html_e('All Settings'); ?></h2> |
170 | <form name="form" action="options.php" method="post" id="all-options"> |
171 | <?php wp_nonce_field('options-options') ?> |
172 | <input type="hidden" name="action" value="update" /> |
173 | <input type='hidden' name='option_page' value='options' /> |
174 | <table class="form-table"> |
175 | <?php |
176 | $options = $wpdb->get_results( "SELECT * FROM $wpdb->options ORDER BY option_name" ); |
177 | |
178 | foreach ( (array) $options as $option ) : |
179 | $disabled = false; |
180 | if ( $option->option_name == '' ) |
181 | continue; |
182 | if ( is_serialized( $option->option_value ) ) { |
183 | if ( is_serialized_string( $option->option_value ) ) { |
184 | // this is a serialized string, so we should display it |
185 | $value = maybe_unserialize( $option->option_value ); | //Possible Control Flow
|
186 | $options_to_update[] = $option->option_name; |
187 | $class = 'all-options'; |
188 | } else { |
189 | $value = 'SERIALIZED DATA'; |
190 | $disabled = true; |
191 | $class = 'all-options disabled'; |
192 | } |
193 | } else { |
194 | $value = $option->option_value; |
195 | $options_to_update[] = $option->option_name; |
196 | $class = 'all-options'; |
197 | } |
198 | $name = esc_attr( $option->option_name ); |
199 | echo " |
200 | <tr> |
201 | <th scope='row'><label for='$name'>" . esc_html( $option->option_name ) . "</label></th> |
202 | <td>"; |
203 | if ( strpos( $value, "\n" ) !== false ) |
204 | echo "<textarea class='$class' name='$name' id='$name' cols='30' rows='5'>" . wp_htmledit_pre( $value ) . "</textarea>"; |
205 | else |
206 | echo "<input class='regular-text $class' type='text' name='$name' id='$name' value='" . esc_attr( $value ) . "'" . disabled( $disabled, true, false ) . " />"; |
207 | echo "</td> |
208 | </tr>"; |
209 | endforeach; |
210 | ?> |
211 | </table> |
212 | <p class="submit"><input type="hidden" name="page_options" value="<?php echo esc_attr( implode( ',', $options_to_update ) ); ?>" /><input type="submit" name="Update" value="<?php esc_attr_e( 'Save Changes' ); ?>" class="button-primary" /></p> |
213 | </form> |
214 | </div> |
215 | |
216 | |
217 | <?php |
218 | include('./admin-footer.php'); |
219 | ?> |
220 | |