root/wp-polls/trunk/polls-uninstall.php

Revision 49932, 5.6 kB (checked in by GamerZ, 4 weeks ago)

Fixed MYSQL Charset Issue

Line 
1 <?php
2 /*
3 +----------------------------------------------------------------+
4 |                                                                                            |
5 |    WordPress 2.5 Plugin: WP-Polls 2.31                                        |
6 |    Copyright (c) 2008 Lester "GaMerZ" Chan                                    |
7 |                                                                                            |
8 |    File Written By:                                                                    |
9 |    - Lester "GaMerZ" Chan                                                            |
10 |    - http://lesterchan.net                                                            |
11 |                                                                                            |
12 |    File Information:                                                                    |
13 |    - Uninstall WP-Polls                                                                |
14 |    - wp-content/plugins/wp-polls/polls-uninstall.php                        |
15 |                                                                                            |
16 +----------------------------------------------------------------+
17 */
18
19
20 ### Check Whether User Can Manage Polls
21 if(!current_user_can('manage_polls')) {
22     die('Access Denied');
23 }
24
25
26 ### Variables Variables Variables
27 $base_name = plugin_basename('wp-polls/polls-manager.php');
28 $base_page = 'admin.php?page='.$base_name;
29 $mode = trim($_GET['mode']);
30 $polls_tables = array($wpdb->pollsq, $wpdb->pollsa, $wpdb->pollsip);
31 $polls_settings = array('poll_template_voteheader', 'poll_template_votebody', 'poll_template_votefooter', 'poll_template_resultheader', 'poll_template_resultbody', 'poll_template_resultbody2', 'poll_template_resultfooter', 'poll_template_resultfooter2''poll_template_disable', 'poll_template_error', 'poll_currentpoll', 'poll_latestpoll', 'poll_archive_perpage', 'poll_ans_sortby', 'poll_ans_sortorder', 'poll_ans_result_sortby', 'poll_ans_result_sortorder', 'poll_logging_method', 'poll_allowtovote', 'poll_archive_show', 'poll_archive_url', 'poll_bar', 'poll_close', 'poll_ajax_style', 'poll_template_pollarchivelink', 'widget_polls', 'poll_archive_displaypoll', 'poll_template_pollarchiveheader', 'poll_template_pollarchivefooter', 'poll_cookielog_expiry');
32
33
34 ### Form Processing
35 if(!empty($_POST['do'])) {
36     // Decide What To Do
37     switch($_POST['do']) {
38         //  Uninstall WP-Polls (By: Philippe Corbes)
39         case __('UNINSTALL WP-Polls', 'wp-polls') :
40             if(trim($_POST['uninstall_poll_yes']) == 'yes') {
41                 echo '<div id="message" class="updated fade">';
42                 echo '<p>';
43                 foreach($polls_tables as $table) {
44                     $wpdb->query("DROP TABLE {$table}");
45                     echo '<font style="color: green;">';
46                     printf(__('Table \'%s\' has been deleted.', 'wp-polls'), "<strong><em>{$table}</em></strong>");
47                     echo '</font><br />';
48                 }
49                 echo '</p>';
50                 echo '<p>';
51                 foreach($polls_settings as $setting) {
52                     $delete_setting = delete_option($setting);
53                     if($delete_setting) {
54                         echo '<font color="green">';
55                         printf(__('Setting Key \'%s\' has been deleted.', 'wp-polls'), "<strong><em>{$setting}</em></strong>");
56                         echo '</font><br />';
57                     } else {
58                         echo '<font color="red">';
59                         printf(__('Error deleting Setting Key \'%s\'.', 'wp-polls'), "<strong><em>{$setting}</em></strong>");
60                         echo '</font><br />';
61                     }
62                 }
63                 echo '</p>';
64                 echo '</div>';
65                 $mode = 'end-UNINSTALL';
66             }
67             break;
68     }
69 }
70
71
72 ### Determines Which Mode It Is
73 switch($mode) {
74         //  Deactivating WP-Polls (By: Philippe Corbes)
75         case 'end-UNINSTALL':
76             $deactivate_url = 'plugins.php?action=deactivate&amp;plugin=wp-polls/wp-polls.php';
77             if(function_exists('wp_nonce_url')) {
78                 $deactivate_url = wp_nonce_url($deactivate_url, 'deactivate-plugin_wp-polls/wp-polls.php');
79             }
80             echo '<div class="wrap">';
81             echo '<h2>'.__('Uninstall WP-Polls', 'wp-polls').'</h2>';
82             echo '<p><strong>'.sprintf(__('<a href="%s">Click Here</a> To Finish The Uninstallation And WP-Polls Will Be Deactivated Automatically.', 'wp-polls'), $deactivate_url).'</strong></p>';
83             echo '</div>';
84             break;
85     // Main Page
86     default:
87 ?>
88 <!-- Uninstall WP-Polls (By: Philippe Corbes) -->
89 <form action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?>" method="post">
90 <div class="wrap">
91     <h2><?php _e('Uninstall WP-Polls', 'wp-polls'); ?></h2>
92     <p style="text-align: left;">
93         <?php _e('Deactivating WP-Polls plugin does not remove any data that may have been created, such as the poll data and the poll\'s voting logs. To completely remove this plugin, you can uninstall it here.', 'wp-polls'); ?>
94     </p>
95     <p style="text-align: left; color: red">
96         <strong><?php _e('WARNING:', 'wp-polls'); ?></strong><br />
97         <?php _e('Once uninstalled, this cannot be undone. You should use a Database Backup plugin of WordPress to back up all the data first.', 'wp-polls'); ?>
98     </p>
99     <p style="text-align: left; color: red">
100         <strong><?php _e('The following WordPress Options/Tables will be DELETED:', 'wp-polls'); ?></strong><br />
101     </p>
102     <table class="widefat">
103         <thead>
104             <tr>
105                 <th><?php _e('WordPress Options', 'wp-polls'); ?></th>
106                 <th><?php _e('WordPress Tables', 'wp-polls'); ?></th>
107             </tr>
108         </thead>
109         <tr>
110             <td valign="top">
111                 <ol>
112                 <?php
113                     foreach($polls_settings as $settings) {
114                         echo '<li>'.$settings.'</li>'."\n";
115                     }
116                 ?>
117                 </ol>
118             </td>
119             <td valign="top" class="alternate">
120                 <ol>
121                 <?php
122                     foreach($polls_tables as $tables) {
123                         echo '<li>'.$tables.'</li>'."\n";
124                     }
125                 ?>
126                 </ol>
127             </td>
128         </tr>
129     </table>
130     <p style="text-align: center;">
131         <?php _e('Do you really want to uninstall WP-Polls?', 'wp-polls'); ?><br /><br />
132         <input type="checkbox" name="uninstall_poll_yes" value="yes" />&nbsp;<?php _e('Yes', 'wp-polls'); ?><br /><br />
133         <input type="submit" name="do" value="<?php _e('UNINSTALL WP-Polls', 'wp-polls'); ?>" class="button" onclick="return confirm('<?php _e('You Are About To Uninstall WP-Polls From WordPress.\nThis Action Is Not Reversible.\n\n Choose [Cancel] To Stop, [OK] To Uninstall.', 'wp-polls'); ?>')" />
134     </p>
135 </div>
136 </form>
137 <?php
138 } // End switch($mode)
139 ?>
Note: See TracBrowser for help on using the browser.