]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/options.php
Wordpress 2.0.4
[autoinstalls/wordpress.git] / wp-admin / options.php
1 <?php
2 require_once('admin.php');
3
4 $title = __('Options');
5 $this_file = 'options.php';
6 $parent_file = 'options-general.php';
7
8 $wpvarstoreset = array('action');
9 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
10         $wpvar = $wpvarstoreset[$i];
11         if (!isset($$wpvar)) {
12                 if (empty($_POST["$wpvar"])) {
13                         if (empty($_GET["$wpvar"])) {
14                                 $$wpvar = '';
15                         } else {
16                                 $$wpvar = $_GET["$wpvar"];
17                         }
18                 } else {
19                         $$wpvar = $_POST["$wpvar"];
20                 }
21         }
22 }
23
24 if ( !current_user_can('manage_options') )
25         die ( __('Cheatin&#8217; uh?') );
26
27 switch($action) {
28
29 case 'update':
30         $any_changed = 0;
31         
32         check_admin_referer('update-options');
33
34         if (!$_POST['page_options']) {
35                 foreach ($_POST as $key => $value) {
36                         $options[] = $key;
37                 }
38         } else {
39                 $options = explode(',', stripslashes($_POST['page_options']));
40         }
41
42         // Save for later.
43         $old_siteurl = get_settings('siteurl');
44         $old_home = get_settings('home');
45
46         // HACK
47         // Options that if not there have 0 value but need to be something like "closed"
48         $nonbools = array('default_ping_status', 'default_comment_status');
49         if ($options) {
50                 foreach ($options as $option) {
51                         $option = trim($option);
52                         $value = trim(stripslashes($_POST[$option]));
53                                 if( in_array($option, $nonbools) && ( $value == '0' || $value == '') )
54                                 $value = 'closed';
55                         
56                         if( $option == 'blogdescription' || $option == 'blogname' )
57                                 if (current_user_can('unfiltered_html') == false)
58                                         $value = wp_filter_post_kses( $value );
59                         
60                         if (update_option($option, $value) ) {
61                                 $any_changed++;
62                         }
63                 }
64         }
65     
66         if ($any_changed) {
67                         // If siteurl or home changed, reset cookies.
68                         if ( get_settings('siteurl') != $old_siteurl || get_settings('home') != $old_home ) {
69                                 // If home changed, write rewrite rules to new location.
70                                 $wp_rewrite->flush_rules();
71                                 // Clear cookies for old paths.
72                                 wp_clearcookie();
73                                 // Set cookies for new paths.
74                                 wp_setcookie($user_login, $user_pass_md5, true, get_settings('home'), get_settings('siteurl'));
75                         }
76
77                         //$message = sprintf(__('%d setting(s) saved... '), $any_changed);
78     }
79     
80         $referred = remove_query_arg('updated' , wp_get_referer());
81         $goback = add_query_arg('updated', 'true', wp_get_referer());
82         $goback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $goback);
83         wp_redirect($goback);
84     break;
85
86 default:
87         include('admin-header.php'); ?>
88
89 <div class="wrap">
90   <h2><?php _e('All options'); ?></h2>
91   <form name="form" action="options.php" method="post">
92   <?php wp_nonce_field('update-options') ?>
93   <input type="hidden" name="action" value="update" />
94   <table width="98%">
95 <?php
96 $options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name");
97
98 foreach ($options as $option) :
99         $value = wp_specialchars($option->option_value);
100         echo "
101 <tr>
102         <th scope='row'><label for='$option->option_name'>$option->option_name</label></th>
103         <td><input type='text' name='$option->option_name' id='$option->option_name' size='30' value='" . $value . "' /></td>
104         <td>$option->option_description</td>
105 </tr>";
106 endforeach;
107 ?>
108   </table>
109 <p class="submit"><input type="submit" name="Update" value="<?php _e('Update Settings &raquo;') ?>" /></p>
110   </form>
111 </div>
112
113
114 <?php
115 break;
116 } // end switch
117
118 include('admin-footer.php');
119 ?>