| 23 | | |
| 24 | | ### If Form Is Submitted |
| 25 | | if($_POST['Submit']) { |
| 26 | | $useronline_bots = array(); |
| 27 | | $useronline_timeout = intval($_POST['useronline_timeout']); |
| 28 | | $useronline_bots_name = explode("\n", trim($_POST['useronline_bots_name'])); |
| 29 | | $useronline_bots_agent = explode("\n", trim($_POST['useronline_bots_agent'])); |
| 30 | | $useronline_bots_keys = array_values((array) $useronline_bots_name); |
| 31 | | $useronline_bots_vals = array_values((array) $useronline_bots_agent); |
| 32 | | $n = max(count($useronline_bots_keys), count($useronline_bots_vals)); |
| 33 | | for($i = 0; $i < $n; $i++) { |
| 34 | | $useronline_bots[trim($useronline_bots_keys[$i])] = trim($useronline_bots_vals[$i]); |
| 35 | | } |
| 36 | | $useronline_url = addslashes(trim($_POST['useronline_url'])); |
| 37 | | $update_useronline_queries = array(); |
| 38 | | $update_useronline_text = array(); |
| 39 | | $update_useronline_queries[] = update_option('useronline_timeout', $useronline_timeout); |
| 40 | | $update_useronline_queries[] = update_option('useronline_bots', $useronline_bots); |
| 41 | | $update_useronline_queries[] = update_option('useronline_url', $useronline_url); |
| 42 | | $update_useronline_text[] = __('Useronline Timeout', 'wp-useronline'); |
| 43 | | $update_useronline_text[] = __('Useronline Bots', 'wp-useronline'); |
| 44 | | $update_useronline_text[] = __('Useronline URL', 'wp-useronline'); |
| 45 | | $i=0; |
| 46 | | $text = ''; |
| 47 | | foreach($update_useronline_queries as $update_useronline_query) { |
| 48 | | if($update_useronline_query) { |
| 49 | | $text .= '<font color="green">'.$update_useronline_text[$i].' '.__('Updated', 'wp-useronline').'</font><br />'; |
| 50 | | } |
| 51 | | $i++; |
| 52 | | } |
| 53 | | if(empty($text)) { |
| 54 | | $text = '<font color="red">'.__('No Useronline Option Updated', 'wp-useronline').'</font>'; |
| | 23 | $mode = trim($_GET['mode']); |
| | 24 | $useronline_tables = array($wpdb->useronline); |
| | 25 | $useronline_settings = array('useronline_most_users', 'useronline_most_timestamp', 'useronline_timeout', 'useronline_bots', 'useronline_url', 'widget_useronline'); |
| | 26 | |
| | 27 | |
| | 28 | ### Form Processing |
| | 29 | if(!empty($_POST['do'])) { |
| | 30 | // Decide What To Do |
| | 31 | switch($_POST['do']) { |
| | 32 | case __('Update Options', 'wp-useronline'): |
| | 33 | $useronline_bots = array(); |
| | 34 | $useronline_timeout = intval($_POST['useronline_timeout']); |
| | 35 | $useronline_bots_name = explode("\n", trim($_POST['useronline_bots_name'])); |
| | 36 | $useronline_bots_agent = explode("\n", trim($_POST['useronline_bots_agent'])); |
| | 37 | $useronline_bots_keys = array_values((array) $useronline_bots_name); |
| | 38 | $useronline_bots_vals = array_values((array) $useronline_bots_agent); |
| | 39 | $n = max(count($useronline_bots_keys), count($useronline_bots_vals)); |
| | 40 | for($i = 0; $i < $n; $i++) { |
| | 41 | $useronline_bots[trim($useronline_bots_keys[$i])] = trim($useronline_bots_vals[$i]); |
| | 42 | } |
| | 43 | $useronline_url = addslashes(trim($_POST['useronline_url'])); |
| | 44 | $update_useronline_queries = array(); |
| | 45 | $update_useronline_text = array(); |
| | 46 | $update_useronline_queries[] = update_option('useronline_timeout', $useronline_timeout); |
| | 47 | $update_useronline_queries[] = update_option('useronline_bots', $useronline_bots); |
| | 48 | $update_useronline_queries[] = update_option('useronline_url', $useronline_url); |
| | 49 | $update_useronline_text[] = __('Useronline Timeout', 'wp-useronline'); |
| | 50 | $update_useronline_text[] = __('Useronline Bots', 'wp-useronline'); |
| | 51 | $update_useronline_text[] = __('Useronline URL', 'wp-useronline'); |
| | 52 | $i=0; |
| | 53 | $text = ''; |
| | 54 | foreach($update_useronline_queries as $update_useronline_query) { |
| | 55 | if($update_useronline_query) { |
| | 56 | $text .= '<font color="green">'.$update_useronline_text[$i].' '.__('Updated', 'wp-useronline').'</font><br />'; |
| | 57 | } |
| | 58 | $i++; |
| | 59 | } |
| | 60 | if(empty($text)) { |
| | 61 | $text = '<font color="red">'.__('No Useronline Option Updated', 'wp-useronline').'</font>'; |
| | 62 | } |
| | 63 | break; |
| | 64 | // Uninstall WP-UserOnline |
| | 65 | case __('UNINSTALL WP-UserOnline', 'wp-useronline') : |
| | 66 | if(trim($_POST['uninstall_useronline_yes']) == 'yes') { |
| | 67 | echo '<div id="message" class="updated fade">'; |
| | 68 | echo '<p>'; |
| | 69 | foreach($useronline_tables as $table) { |
| | 70 | $wpdb->query("DROP TABLE {$table}"); |
| | 71 | echo '<font style="color: green;">'; |
| | 72 | printf(__('Table \'%s\' has been deleted.', 'wp-useronline'), "<strong><em>{$table}</em></strong>"); |
| | 73 | echo '</font><br />'; |
| | 74 | } |
| | 75 | echo '</p>'; |
| | 76 | echo '<p>'; |
| | 77 | foreach($useronline_settings as $setting) { |
| | 78 | $delete_setting = delete_option($setting); |
| | 79 | if($delete_setting) { |
| | 80 | echo '<font color="green">'; |
| | 81 | printf(__('Setting Key \'%s\' has been deleted.', 'wp-useronline'), "<strong><em>{$setting}</em></strong>"); |
| | 82 | echo '</font><br />'; |
| | 83 | } else { |
| | 84 | echo '<font color="red">'; |
| | 85 | printf(__('Error deleting Setting Key \'%s\'.', 'wp-useronline'), "<strong><em>{$setting}</em></strong>"); |
| | 86 | echo '</font><br />'; |
| | 87 | } |
| | 88 | } |
| | 89 | echo '</p>'; |
| | 90 | echo '</div>'; |
| | 91 | $mode = 'end-UNINSTALL'; |
| | 92 | } |
| | 93 | break; |
| 58 | | ### Get Useronline Bots |
| 59 | | $useronline_options_bots = get_option('useronline_bots'); |
| 60 | | $useronline_options_bots_name = ''; |
| 61 | | $useronline_options_bots_agent = ''; |
| 62 | | foreach($useronline_options_bots as $botname => $botagent) { |
| 63 | | $useronline_options_bots_name .= $botname."\n"; |
| 64 | | $useronline_options_bots_agent .= $botagent."\n"; |
| 65 | | } |
| 66 | | $useronline_options_bots_name = trim($useronline_options_bots_name); |
| 67 | | $useronline_options_bots_agent = trim($useronline_options_bots_agent); |
| | 97 | |
| | 98 | ### Determines Which Mode It Is |
| | 99 | switch($mode) { |
| | 100 | // Deactivating WP-UserOnline |
| | 101 | case 'end-UNINSTALL': |
| | 102 | $deactivate_url = 'plugins.php?action=deactivate&plugin=useronline/useronline.php'; |
| | 103 | if(function_exists('wp_nonce_url')) { |
| | 104 | $deactivate_url = wp_nonce_url($deactivate_url, 'deactivate-plugin_useronline/useronline.php'); |
| | 105 | } |
| | 106 | echo '<div class="wrap">'; |
| | 107 | echo '<h2>'.__('Uninstall WP-UserOnline', 'wp-useronline').'</h2>'; |
| | 108 | echo '<p><strong>'.sprintf(__('<a href="%s">Click Here</a> To Finish The Uninstallation And WP-UserOnline Will Be Deactivated Automatically.', 'wp-useronline'), $deactivate_url).'</strong></p>'; |
| | 109 | echo '</div>'; |
| | 110 | break; |
| | 111 | // Main Page |
| | 112 | default: |
| | 113 | $useronline_options_bots = get_option('useronline_bots'); |
| | 114 | $useronline_options_bots_name = ''; |
| | 115 | $useronline_options_bots_agent = ''; |
| | 116 | foreach($useronline_options_bots as $botname => $botagent) { |
| | 117 | $useronline_options_bots_name .= $botname."\n"; |
| | 118 | $useronline_options_bots_agent .= $botagent."\n"; |
| | 119 | } |
| | 120 | $useronline_options_bots_name = trim($useronline_options_bots_name); |
| | 121 | $useronline_options_bots_agent = trim($useronline_options_bots_agent); |
| 72 | | <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> |
| 73 | | <fieldset class="options"> |
| 74 | | <legend><?php _e('Useronline Options', 'wp-useronline'); ?></legend> |
| 75 | | <table width="100%" border="0" cellspacing="3" cellpadding="3"> |
| 76 | | <tr valign="top"> |
| 77 | | <th align="left" width="30%"><?php _e('Time Out', 'wp-useronline'); ?></th> |
| 78 | | <td align="left"> |
| 79 | | <input type="text" name="useronline_timeout" value="<?php echo get_option('useronline_timeout'); ?>" size="4" /><br /><?php _e('How long till it will remove the user from the database (In seconds).', 'wp-useronline'); ?> |
| 80 | | </td> |
| 81 | | </tr> |
| 82 | | <tr valign="top"> |
| 83 | | <th align="left" width="30%"><?php _e('UserOnline URL', 'wp-useronline'); ?></th> |
| 84 | | <td align="left"> |
| 85 | | <input type="text" name="useronline_url" value="<?php echo get_option('useronline_url'); ?>" size="50" /><br /><?php _e('URL To UserOnline Page (leave blank if you do not want to link it to the UserOnline Page)<br />Example: http://www.yoursite.com/blogs/useronline/<br />Example: http://www.yoursite.com/blogs/?page_id=2', 'wp-useronline'); ?> |
| 86 | | </td> |
| 87 | | </tr> |
| 88 | | <tr valign="top"> |
| 89 | | <th align="left" width="30%"><?php _e('Bots Name/User Agent', 'wp-useronline'); ?></th> |
| 90 | | <td align="left"> |
| 91 | | <?php _e('Here are a list of bots and their partial browser agents.<br />On the left column will be the <strong>Bot\'s Name</strong> and on the right column will be their <strong>Partial Browser Agent</strong>.<br />Start each entry on a new line.', 'wp-useronline'); ?> |
| 92 | | <br /><br /> |
| 93 | | <textarea cols="20" rows="30" name="useronline_bots_name"><?php echo $useronline_options_bots_name; ?></textarea> |
| 94 | | <textarea cols="20" rows="30" name="useronline_bots_agent"><?php echo $useronline_options_bots_agent; ?></textarea> |
| 95 | | </td> |
| 96 | | </tr> |
| 97 | | </table> |
| 98 | | </fieldset> |
| 99 | | <div align="center"> |
| 100 | | <input type="submit" name="Submit" class="button" value="<?php _e('Update Options', 'wp-useronline'); ?>" /> <input type="button" name="cancel" value="<?php _e('Cancel', 'wp-useronline'); ?>" class="button" onclick="javascript:history.go(-1)" /> |
| 101 | | </div> |
| 102 | | </form> |
| | 127 | <fieldset class="options"> |
| | 128 | <legend><?php _e('Useronline Options', 'wp-useronline'); ?></legend> |
| | 129 | <table width="100%" border="0" cellspacing="3" cellpadding="3"> |
| | 130 | <tr valign="top"> |
| | 131 | <th align="left" width="30%"><?php _e('Time Out', 'wp-useronline'); ?></th> |
| | 132 | <td align="left"> |
| | 133 | <input type="text" name="useronline_timeout" value="<?php echo get_option('useronline_timeout'); ?>" size="4" /><br /><?php _e('How long till it will remove the user from the database (In seconds).', 'wp-useronline'); ?> |
| | 134 | </td> |
| | 135 | </tr> |
| | 136 | <tr valign="top"> |
| | 137 | <th align="left" width="30%"><?php _e('UserOnline URL', 'wp-useronline'); ?></th> |
| | 138 | <td align="left"> |
| | 139 | <input type="text" name="useronline_url" value="<?php echo get_option('useronline_url'); ?>" size="50" /><br /><?php _e('URL To UserOnline Page (leave blank if you do not want to link it to the UserOnline Page)<br />Example: http://www.yoursite.com/blogs/useronline/<br />Example: http://www.yoursite.com/blogs/?page_id=2', 'wp-useronline'); ?> |
| | 140 | </td> |
| | 141 | </tr> |
| | 142 | <tr valign="top"> |
| | 143 | <th align="left" width="30%"><?php _e('Bots Name/User Agent', 'wp-useronline'); ?></th> |
| | 144 | <td align="left"> |
| | 145 | <?php _e('Here are a list of bots and their partial browser agents.<br />On the left column will be the <strong>Bot\'s Name</strong> and on the right column will be their <strong>Partial Browser Agent</strong>.<br />Start each entry on a new line.', 'wp-useronline'); ?> |
| | 146 | <br /><br /> |
| | 147 | <textarea cols="20" rows="30" name="useronline_bots_name"><?php echo $useronline_options_bots_name; ?></textarea> |
| | 148 | <textarea cols="20" rows="30" name="useronline_bots_agent"><?php echo $useronline_options_bots_agent; ?></textarea> |
| | 149 | </td> |
| | 150 | </tr> |
| | 151 | </table> |
| | 152 | </fieldset> |
| | 153 | <div align="center"> |
| | 154 | <input type="submit" name="do" class="button" value="<?php _e('Update Options', 'wp-useronline'); ?>" /> <input type="button" name="cancel" value="<?php _e('Cancel', 'wp-useronline'); ?>" class="button" onclick="javascript:history.go(-1)" /> |
| | 155 | </div> |
| | 156 | </div> |
| | 157 | </form> |
| | 158 | |
| | 159 | <!-- Uninstall WP-UserOnline --> |
| | 160 | <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>"> |
| | 161 | <div class="wrap"> |
| | 162 | <h2><?php _e('Uninstall WP-UserOnline', 'wp-useronline'); ?></h2> |
| | 163 | <p style="text-align: left;"> |
| | 164 | <?php _e('Deactivating WP-UserOnline plugin does not remove any data that may have been created, such as the useronline options. To completely remove this plugin, you can uninstall it here.', 'wp-useronline'); ?> |
| | 165 | </p> |
| | 166 | <p style="text-align: left; color: red"> |
| | 167 | <strong><?php _e('WARNING:', 'wp-useronline'); ?></strong><br /> |
| | 168 | <?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-useronline'); ?> |
| | 169 | </p> |
| | 170 | <p style="text-align: left; color: red"> |
| | 171 | <strong><?php _e('The following WordPress Options/Tables will be DELETED:', 'wp-useronline'); ?></strong><br /> |
| | 172 | </p> |
| | 173 | <table width="70%" border="0" cellspacing="3" cellpadding="3"> |
| | 174 | <tr class="thead"> |
| | 175 | <td align="center"><strong><?php _e('WordPress Options', 'wp-useronline'); ?></strong></td> |
| | 176 | <td align="center"><strong><?php _e('WordPress Tables', 'wp-useronline'); ?></strong></td> |
| | 177 | </tr> |
| | 178 | <tr> |
| | 179 | <td valign="top" style="background-color: #eee;"> |
| | 180 | <ol> |
| | 181 | <?php |
| | 182 | foreach($useronline_settings as $settings) { |
| | 183 | echo '<li>'.$settings.'</li>'."\n"; |
| | 184 | } |
| | 185 | ?> |
| | 186 | </ol> |
| | 187 | </td> |
| | 188 | <td valign="top" style="background-color: #eee;"> |
| | 189 | <ol> |
| | 190 | <?php |
| | 191 | foreach($useronline_tables as $tables) { |
| | 192 | echo '<li>'.$tables.'</li>'."\n"; |
| | 193 | } |
| | 194 | ?> |
| | 195 | </ol> |
| | 196 | </td> |
| | 197 | </tr> |
| | 198 | </table> |
| | 199 | <p> </p> |
| | 200 | <p style="text-align: center;"> |
| | 201 | <input type="checkbox" name="uninstall_useronline_yes" value="yes" /> <?php _e('Yes', 'wp-useronline'); ?><br /><br /> |
| | 202 | <input type="submit" name="do" value="<?php _e('UNINSTALL WP-UserOnline', 'wp-useronline'); ?>" class="button" onclick="return confirm('<?php _e('You Are About To Uninstall WP-UserOnline From WordPress.\nThis Action Is Not Reversible.\n\n Choose [Cancel] To Stop, [OK] To Uninstall.', 'wp-useronline'); ?>')" /> |
| | 203 | </p> |