]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/options.php
Wordpress 2.7.1-scripts
[autoinstalls/wordpress.git] / wp-admin / options.php
1 <?php
2 /**
3  * Options Management Administration Panel.
4  *
5  * Just allows for displaying of options.
6  *
7  * This isn't referenced or linked to, but will show all of the options and
8  * allow editing. The issue is that serialized data is not supported to be
9  * modified. Options can not be removed.
10  *
11  * @package WordPress
12  * @subpackage Administration
13  */
14
15 /** WordPress Administration Bootstrap */
16 require_once('admin.php');
17
18 $title = __('Settings');
19 $this_file = 'options.php';
20 $parent_file = 'options-general.php';
21
22 wp_reset_vars(array('action'));
23
24 $whitelist_options = array(
25         'general' => array( 'blogname', 'blogdescription', 'admin_email', 'users_can_register', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'default_role' ),
26         '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' ),
27         'misc' => array( 'hack_file', 'use_linksupdate', 'uploads_use_yearmonth_folders', 'upload_path', 'upload_url_path' ),
28         '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' ),
29         'privacy' => array( 'blog_public' ),
30         'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'blog_charset', 'show_on_front', 'page_on_front', 'page_for_posts' ),
31         'writing' => array( 'default_post_edit_rows', 'use_smilies', 'ping_sites', 'mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'enable_app', 'enable_xmlrpc' ),
32         'options' => array( '' ) );
33 if ( !defined( 'WP_SITEURL' ) ) $whitelist_options['general'][] = 'siteurl';
34 if ( !defined( 'WP_HOME' ) ) $whitelist_options['general'][] = 'home';
35
36 $whitelist_options = apply_filters( 'whitelist_options', $whitelist_options );
37
38 if ( !current_user_can('manage_options') )
39         wp_die(__('Cheatin&#8217; uh?'));
40
41 switch($action) {
42
43 case 'update':
44         if ( isset($_POST[ 'option_page' ]) ) {
45                 $option_page = $_POST[ 'option_page' ];
46                 check_admin_referer( $option_page . '-options' );
47         } else {
48                 // This is for back compat and will eventually be removed.
49                 $option_page = 'options';
50                 check_admin_referer( 'update-options' );
51         }
52
53         if ( !isset( $whitelist_options[ $option_page ] ) )
54                 wp_die( __( 'Error! Options page not found.' ) );
55
56         if ( 'options' == $option_page ) {
57                 $options = explode(',', stripslashes( $_POST[ 'page_options' ] ));
58         } else {
59                 $options = $whitelist_options[ $option_page ];
60         }
61
62         // Handle custom date/time formats
63         if ( 'general' == $option_page ) {
64                 if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['date_format'] ) )
65                         $_POST['date_format'] = $_POST['date_format_custom'];
66                 if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['time_format'] ) )
67                         $_POST['time_format'] = $_POST['time_format_custom'];
68         }
69
70         if ( $options ) {
71                 foreach ( $options as $option ) {
72                         $option = trim($option);
73                         $value = null;
74                         if ( isset($_POST[$option]) )
75                                 $value = $_POST[$option];
76                         if ( !is_array($value) ) $value = trim($value);
77                         $value = stripslashes_deep($value);
78                         update_option($option, $value);
79                 }
80         }
81
82         $goback = add_query_arg( 'updated', 'true', wp_get_referer() );
83         wp_redirect( $goback );
84         break;
85
86 default:
87         include('admin-header.php'); ?>
88
89 <div class="wrap">
90 <?php screen_icon(); ?>
91   <h2><?php _e('All Settings'); ?></h2>
92   <form name="form" action="options.php" method="post" id="all-options">
93   <?php wp_nonce_field('options-options') ?>
94   <input type="hidden" name="action" value="update" />
95   <input type='hidden' name='option_page' value='options' />
96   <table class="form-table">
97 <?php
98 $options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name");
99
100 foreach ( (array) $options as $option) :
101         $disabled = '';
102         $option->option_name = attribute_escape($option->option_name);
103         if ( is_serialized($option->option_value) ) {
104                 if ( is_serialized_string($option->option_value) ) {
105                         // this is a serialized string, so we should display it
106                         $value = maybe_unserialize($option->option_value);
107                         $options_to_update[] = $option->option_name;
108                         $class = 'all-options';
109                 } else {
110                         $value = 'SERIALIZED DATA';
111                         $disabled = ' disabled="disabled"';
112                         $class = 'all-options disabled';
113                 }
114         } else {
115                 $value = $option->option_value;
116                 $options_to_update[] = $option->option_name;
117                 $class = 'all-options';
118         }
119         echo "
120 <tr>
121         <th scope='row'><label for='$option->option_name'>$option->option_name</label></th>
122 <td>";
123
124         if (strpos($value, "\n") !== false) echo "<textarea class='$class' name='$option->option_name' id='$option->option_name' cols='30' rows='5'>" . wp_specialchars($value) . "</textarea>";
125         else echo "<input class='regular-text $class' type='text' name='$option->option_name' id='$option->option_name' value='" . attribute_escape($value) . "'$disabled />";
126
127         echo "</td>
128 </tr>";
129 endforeach;
130 ?>
131   </table>
132 <?php $options_to_update = implode(',', $options_to_update); ?>
133 <p class="submit"><input type="hidden" name="page_options" value="<?php echo $options_to_update; ?>" /><input type="submit" name="Update" value="<?php _e('Save Changes') ?>" class="button-primary" /></p>
134   </form>
135 </div>
136
137
138 <?php
139 break;
140 } // end switch
141
142 include('admin-footer.php');
143 ?>