function act_admin_settings() { global $wpdb, $act_plugin_version, $act_list_limit; if (isset($_POST['submit']) && check_admin_referer('wp-activity-submit', 'act_admin')) { if (substr($_POST['act_author_path'], -1, 1) == '/') { $_POST['act_author_path'] = substr($_POST['act_author_path'], 0, -1); } $options_act['act_connect'] = isset($_POST['act_connect']) ? $_POST['act_connect'] : ''; $options_act['act_profiles'] = isset($_POST['act_profiles']) ? $_POST['act_profiles'] : ''; $options_act['act_posts'] = isset($_POST['act_posts']) ? $_POST['act_posts'] : ''; $options_act['act_comments'] = isset($_POST['act_comments']) ? $_POST['act_comments'] : ''; $options_act['act_links'] = isset($_POST['act_links']) ? $_POST['act_links'] : ''; $options_act['act_feed_connect'] = isset($_POST['act_feed_connect']) ? $_POST['act_feed_connect'] : ''; $options_act['act_feed_profiles'] = isset($_POST['act_feed_profiles']) ? $_POST['act_feed_profiles'] : ''; $options_act['act_feed_posts'] = isset($_POST['act_feed_posts']) ? $_POST['act_feed_posts'] : ''; $options_act['act_feed_comments'] = isset($_POST['act_feed_comments']) ? $_POST['act_feed_comments'] : ''; $options_act['act_feed_links'] = isset($_POST['act_feed_links']) ? $_POST['act_feed_links'] : ''; $options_act['act_feed_display'] = isset($_POST['act_feed_display']) ? $_POST['act_feed_display'] : ''; $options_act['act_prune'] = isset($_POST['act_prune']) ? $_POST['act_prune'] : ''; $options_act['act_date_format'] = isset($_POST['act_date_format']) ? $_POST['act_date_format'] : ''; $options_act['act_date_relative'] = isset($_POST['act_date_relative']) ? $_POST['act_date_relative'] : ''; $options_act['act_icons'] = isset($_POST['act_icons']) ? $_POST['act_icons'] : ''; $options_act['act_old'] = isset($_POST['act_old']) ? $_POST['act_old'] : ''; $options_act['act_page_link'] = isset($_POST['act_page_link']) ? $_POST['act_page_link'] : ''; $options_act['act_page_id'] = isset($_POST['act_page_id']) ? $_POST['act_page_id'] : ''; $options_act['act_prevent_priv'] = isset($_POST['act_prevent_priv']) ? $_POST['act_prevent_priv'] : ''; $options_act['act_log_failures'] = isset($_POST['act_log_failures']) ? $_POST['act_log_failures'] : ''; $options_act['act_author_path'] = isset($_POST['act_author_path']) ? $_POST['act_author_path'] : ''; $options_act['act_blacklist_on'] = isset($_POST['act_blacklist_on']) ? $_POST['act_blacklist_on'] : ''; $options_act['act_bl_wplog'] = isset($_POST['act_bl_wplog']) ? $_POST['act_bl_wplog'] : ''; $options_act['act_blacklist'] = isset($_POST['act_blacklist']) ? $_POST['act_blacklist'] : ''; $options_act['act_auto_bl_n'] = isset($_POST['act_auto_bl_n']) ? $_POST['act_auto_bl_n'] : ''; $options_act['act_auto_bl'] = isset($_POST['act_auto_bl']) ? $_POST['act_auto_bl'] : ''; $options_act['act_refresh'] = isset($_POST['act_refresh']) ? $_POST['act_refresh'] : ''; $options_act['act_version'] = $act_plugin_version; if (update_option('act_settings', $options_act)) { echo '<div id="message" class="updated fade"><p><strong>' . __('Options saved.') . '</strong></p></div>'; } } elseif (isset($_POST['act-reset']) and check_admin_referer('wp-activity-reset', 'act_admin_reset')) { $sql = "DELETE FROM " . $wpdb->prefix . "activity"; if ($results = $wpdb->query($sql)) { echo '<div id="message" class="updated highlight fade"><p><strong>' . __('Activity logs deleted.', 'wp-activity') . '</strong></p></div>'; } } elseif (isset($_POST['act-uninst']) and check_admin_referer('wp-activity-uninst', 'act_admin_uninst')) { act_desactive(); //Delete activity cron delete_option('act_settings'); //delete activity settings $sql = "DROP TABLE " . $wpdb->prefix . "activity"; //delete activity table if ($results = $wpdb->query($sql)) { echo '<div id="message" class="updated highlight fade"><p><strong>' . sprintf(__('Activity Plugin has been uninstalled. You can now desactivate this plugin : <a href="%s">Plugins Page</a>', 'wp-activity'), get_bloginfo('wpurl') . '/wp-admin/plugins.php') . '</strong></p></div>'; } } elseif (isset($_POST['act_prune_now']) and check_admin_referer('wp-activity-submit', 'act_admin')) { $act_success = act_cron($_POST['act_prune']); if ($act_success) { echo '<div id="message" class="updated highlight fade"><p>' . __('Manual pruning done.', 'wp-activity') . '</p></div>'; } } $act_opt = get_option('act_settings'); $act_count = $wpdb->get_var("SELECT count(ID) FROM " . $wpdb->prefix . "activity"); if (!is_array($act_opt)) { echo '<span class="activity_warning">' . sprintf(__('Activity Plugin has been uninstalled. You can now desactivate this plugin : <a href="%s">Plugins Page</a>', 'wp-activity'), get_bloginfo('wpurl') . '/wp-admin/plugins.php') . '</span>'; } else { extract($act_opt); ?> <script type="text/javascript"> jQuery(document).ready( function($) { jQuery( '.nav-tab' ).click(function(){ switch_tabs( $(this) ); jQuery('#footer-thankyou').hide(); }); }); function switch_tabs( obj ) { if ( ! obj.hasClass( 'nav-tab-active' ) ) { jQuery( '.nav-tab-active' ).removeClass( 'nav-tab-active' ); jQuery( '.nav-tab-contents' ).hide( ); var id = '#' + obj.attr( 'rel' ); obj.addClass( 'nav-tab-active' ); jQuery( id ).show(); } }; </script> <div class="wrap"> <h2><?php _e('Settings', 'wp-activity'); ?> </h2> <br/> <div id="slider"> <h2 class="nav-tab-wrapper" > <a class="nav-tab" rel="act_date" href="javascript:void(0);" class="nav-tab nav-tab-active"><?php _e('Date format', 'wp-activity'); ?> </a> <a class="nav-tab" rel="act_display" href="javascript:void(0);" class="nav-tab"><?php _e('Display options', 'wp-activity'); ?> </a> <a class="nav-tab" rel="act_privacy" href="javascript:void(0);" class="nav-tab"><?php _e('Privacy options', 'wp-activity'); ?> </a> <a class="nav-tab" rel="act_events" href="javascript:void(0);" class="nav-tab"><?php _e('Events logging and feeding', 'wp-activity'); ?> </a> <a class="nav-tab" rel="act_bl" href="javascript:void(0);" class="nav-tab"><?php _e('Blacklisting', 'wp-activity'); ?> </a> <a class="nav-tab" rel="act_reset" href="javascript:void(0);" class="nav-tab"><?php _e('Reset/uninstall', 'wp-activity'); ?> </a> </h2> <form action='' method='post'> <div id="act_date" class="nav-tab-contents"> <h3><?php _e('Date format', 'wp-activity'); ?> </h3> <table class="form-table"> <tr valign="top"> <th scope="row"><?php _e('Date format : ', 'wp-activity'); ?> </th> <td> <select name="act_date_format"> <option <?php if ($act_date_format == 'yyyy/mm/dd') { echo "selected='selected' "; } ?> value ="yyyy/mm/dd">yyyy/mm/dd</option> <option <?php if ($act_date_format == 'mm/dd/yyyy') { echo "selected='selected' "; } ?> value ="mm/dd/yyyy">mm/dd/yyyy</option> <option <?php if ($act_date_format == 'dd/mm/yyyy') { echo "selected='selected' "; } ?> value ="dd/mm/yyyy">dd/mm/yyyy</option> </select> <br /><span class="act_info"><?php _e('For events that are more than a month old only, or if you dont use relative dates.', 'wp-activity'); ?> </span> </td> </tr><tr> <th><?php _e('Use relative dates : ', 'wp-activity'); ?> </th> <td> <input type="checkbox" <?php if ($act_date_relative) { echo 'checked="checked"'; } ?> name="act_date_relative" /> <br /><span class="act_info"><?php _e('Relatives dates exemples : 1 day ago, 22 hours and 3 minutes ago, etc.', 'wp-activity'); ?> </span> </td> </tr><tr> </table> <div class="submit"><input type='submit' class='button-primary' name='submit' value='<?php _e('Update options »'); ?> ' /></div> </div> <div id="act_display" class="nav-tab-contents" style="display:none;"> <h3><?php _e('Display options', 'wp-activity'); ?> </h3> <table class="form-table"> <tr> <th><?php _e('Display icons : ', 'wp-activity'); ?> </th> <td><input type="radio" <?php if ($act_icons == "g") { echo 'checked="checked"'; } ?> name="act_icons" value="g" /> <?php _e('Generic icons ', 'wp-activity'); ?> </td> </tr> <tr><td></td><td><input type="radio" <?php if ($act_icons == "a") { echo 'checked="checked"'; } ?> name="act_icons" value="a" /> <?php _e('Gravatars for profile edit and connect events icons', 'wp-activity'); ?> </td></tr> <tr><td></td><td><input type="radio" <?php if ($act_icons == "n") { echo 'checked="checked"'; } ?> name="act_icons" value="n" /> <?php _e('No icons ', 'wp-activity'); ?> </td></tr> <tr> <th><?php _e('Highlight new activity since last user login : '******'wp-activity'); ?> </th> <td><input type="checkbox" <?php if ($act_old) { echo 'checked="checked"'; } ?> name="act_old" /></td> </tr> <tr> <th><?php _e('Use auto-refreshing : ', 'wp-activity'); ?> </th> <td> <input type="checkbox" <?php if ($act_refresh) { echo 'checked="checked"'; } ?> name="act_refresh" /> <?php $act_r_interval = 0; ?> <select name="act_r_interval"> <option <?php if ($act_r_interval == '60') { echo "selected='selected' "; } ?> value ="60">1 <?php _e('minute', 'wp_activity'); ?> </option> <option <?php if ($act_r_interval == '120') { echo "selected='selected' "; } ?> value ="120">2 <?php _e('minutes', 'wp_activity'); ?> </option> <option <?php if ($act_r_interval == '300') { echo "selected='selected' "; } ?> value ="300">5 <?php _e('minutes', 'wp_activity'); ?> </option> <option <?php if ($act_r_interval == '600') { echo "selected='selected' "; } ?> value ="600">10 <?php _e('minutes', 'wp_activity'); ?> </option> <option <?php if ($act_r_interval == '900') { echo "selected='selected' "; } ?> value ="900">15 <?php _e('minutes', 'wp_activity'); ?> </option> <option <?php if ($act_r_interval == '1800') { echo "selected='selected' "; } ?> value ="1800">30 <?php _e('minutes', 'wp_activity'); ?> </option> </select> <br /><span class="act_info"><?php _e('Activity displayed on frontend can be auto-refreshed by AJAX. You can specify the delay between 2 refreshes.', 'wp-activity'); ?> </span> </td> </tr> <tr> <th><?php _e('Display a link to the activity archive page : ', 'wp-activity'); ?> </th> <td> <input type="checkbox" <?php if ($act_page_link) { echo 'checked="checked"'; } ?> name="act_page_link" /> <?php wp_dropdown_pages(array('selected' => $act_page_id, 'name' => 'act_page_id')); ?> <br /><span class="act_info"><?php _e('You have to create a page first, with the [ACT_STREAM] shortcode.', 'wp-activity'); ?> </span> </td> </tr> <tr> <th><?php _e('Author Path : ', 'wp-activity'); ?> </th> <td> <?php echo get_bloginfo('wpurl'); ?> /<input name="act_author_path" type="text" value="<?php echo $act_author_path; ?> " /> <br /><span class="act_info"><?php _e("If you modified your author structure link or if you use WPMu, change your path. (Default : author, BuddyPress : members)", 'wp-activity'); ?> </span> </td> </tr> </table> <div class="submit"><input type='submit' class='button-primary' name='submit' value='<?php _e('Update options »'); ?> ' /></div> </div> <div id="act_privacy" class="nav-tab-contents" style="display:none;"> <h3><?php _e('Privacy options', 'wp-activity'); ?> </h3> <table class="form-table"> <tr> <th><?php _e('Prevent users to hide their activity : ', 'wp-activity'); ?> </th> <td> <input type="checkbox" <?php if ($act_prevent_priv) { echo 'checked="checked"'; } ?> name="act_prevent_priv" /> <br /><span class="activity_warning"><?php _e('Warning : If you activate this option, users won\'t have the choice to allow or deny the logging of their activity. For privacy respect, this option should stay desactivated.', 'wp-activity'); ?> </span> </td> </tr> </table> <div class="submit"><input type='submit' class='button-primary' name='submit' value='<?php _e('Update options »'); ?> ' /></div> </div> <div id="act_events" class="nav-tab-contents" style="display:none;"> <h3><?php _e('Events logging and feeding', 'wp-activity'); ?> </h3> <table class="form-table"> </tr><tr> <th><?php _e('Rows limit in database : ', 'wp-activity'); ?> </th> <td><input type="text" name="act_prune" value="<?php echo $act_prune; ?> " /> <input class="button-secondary" type="submit" name="act_prune_now" value="<?php _e('Manually prune table', 'wp-activity'); ?> " /> <br /><span class="act_info"><?php echo sprintf(__('There is currently %s rows in database.', 'wp-activity'), $act_count); ?> </span> </td> </tr><tr> <th><?php _e('Display activity RSS feed : ', 'wp-activity'); ?> <?php echo act_feed_link(); ?> </th><td><input type="checkbox" <?php if ($act_feed_display) { echo 'checked="checked"'; } ?> name="act_feed_display" /></td> </tr><tr> </tr><tr> <th><?php _e('Log login failures : ', 'wp-activity'); ?> </th> <td> <input type="checkbox" <?php if ($act_log_failures) { echo 'checked="checked"'; } ?> name="act_log_failures" /> <br /><span class="act_info"><?php _e('If you want to log all connexions attempts that failed, enable this option.', 'wp-activity'); ?> </span> </td> </tr><tr> <th></th><th><?php _e('Log in database', 'wp-activity'); ?> </th><th><?php _e('Display in feed', 'wp-activity'); ?> </th> </tr><tr> <th><?php _e('Login events : ', 'wp-activity'); ?> </th> <td><input type="checkbox" <?php if ($act_connect) { echo 'checked="checked"'; } ?> name="act_connect" /></td> <td><input type="checkbox" <?php if ($act_feed_connect) { echo 'checked="checked"'; } ?> name="act_feed_connect" /></td> </tr><tr> <th><?php _e('Profile update/new user events : ', 'wp-activity'); ?> </th> <td><input type="checkbox" <?php if ($act_profiles) { echo 'checked="checked"'; } ?> name="act_profiles" /></td> <td><input type="checkbox" <?php if ($act_feed_profiles) { echo 'checked="checked"'; } ?> name="act_feed_profiles" /></td> </tr><tr> <th><?php _e('Post creation/update/deletion events : ', 'wp-activity'); ?> </th> <td><input type="checkbox" <?php if ($act_posts) { echo 'checked="checked"'; } ?> name="act_posts" /></td> <td><input type="checkbox" <?php if ($act_feed_posts) { echo 'checked="checked"'; } ?> name="act_feed_posts" /></td> </tr><tr> <th><?php _e('New comment events : ', 'wp-activity'); ?> </th> <td><input type="checkbox" <?php if ($act_comments) { echo 'checked="checked"'; } ?> name="act_comments" /></td> <td><input type="checkbox" <?php if ($act_feed_comments) { echo 'checked="checked"'; } ?> name="act_feed_comments" /></td> </tr><tr> <th><?php _e('New link events : ', 'wp-activity'); ?> </th> <td><input type="checkbox" <?php if ($act_links) { echo 'checked="checked"'; } ?> name="act_links" /></td> <td><input type="checkbox" <?php if ($act_feed_links) { echo 'checked="checked"'; } ?> name="act_feed_links" /></td> </tr> </table> <div class="submit"><input type='submit' class='button-primary' name='submit' value='<?php _e('Update options »'); ?> ' /></div> </div> <div id="act_bl" class="nav-tab-contents" style="display:none;"> <h3><?php _e('Blacklisting', 'wp-activity'); ?> </h3> <table class="form-table"> <tr> <th><?php _e('Activate blacklisting', 'wp-activity'); ?> : </th> <td> <input type="checkbox" <?php if ($act_blacklist_on) { echo 'checked="checked"'; } ?> name="act_blacklist_on" /> <br /><span class="act_info"><?php _e('Blacklisting allow to deny access to your blog for specified IP addresses.', 'wp-activity'); ?> </span> </td> </tr> <tr> <th><?php _e('Blacklist on wp-login.php only', 'wp-activity'); ?> : </th> <td> <input type="checkbox" <?php if ($act_bl_wplog) { echo 'checked="checked"'; } ?> name="act_bl_wplog" /> <br /><span class="act_info"><?php _e('Check this option if you don\'t have any frontend login form. For more blog performance, this option should be enabled when possible.', 'wp-activity'); ?> </span> </td> </tr> <tr> <th> <?php _e('Auto-Blacklist IP after ', 'wp-activity'); ?> <select name="act_auto_bl_n"> <?php for ($i = 3; $i < 11; $i++) { ?> <option <?php if ($act_auto_bl_n == $i) { echo "selected='selected'"; } ?> value ="<?php echo $i; ?> "><?php echo $i; ?> </option><?php } ?> </select> <?php _e('failed logon attempts', 'wp-activity'); ?> : </th> <td> <input type="checkbox" <?php if ($act_auto_bl) { echo 'checked="checked"'; } ?> name="act_auto_bl" /> <br /><span class="act_info"><?php _e('If checked, IP addresses will be automatically added to the blacklist after x failed logon attempts during the last 48h.', 'wp-activity'); ?> </span> </td> </tr> <tr> <th><?php _e('IP list', 'wp-activity'); ?> : </th> <td> <?php $act_blacklist = ''; ?> <textarea class="large-text code" rows="6" name="act_blacklist"><?php echo $act_blacklist; ?> </textarea> <br /><span class="act_info"><?php _e('One IP per line. Don\'t blacklist your own IP ! Examples:', 'wp-activity'); ?> 192.168.10.103, 192.168.10.*, 192.168.10.[0-9]</span> </td> </tr> </table> <div class="submit"><input type='submit' class='button-primary' name='submit' value='<?php _e('Update options »'); ?> ' /></div> </div> <?php wp_nonce_field('wp-activity-submit', 'act_admin'); ?> </form><!-- form --> <div id="act_reset" class="nav-tab-contents" style="display:none;"> <h3><?php _e('Reset/uninstall', 'wp-activity'); ?> </h3> <table class="form-table"> </tr><tr> <th><?php _e('Empty activity table : ', 'wp-activity'); ?> </th> <td> <form name="act_form_reset" method="post"> <?php if (function_exists('wp_nonce_field')) { wp_nonce_field('wp-activity-reset', 'act_admin_reset'); } ?> <input type="submit" class="button" name="act-reset" value="<?php _e('Reset logs', 'wp-activity'); ?> " onclick="javascript:check=confirm('<?php _e('Empty activity table ? All your activity logs will be deleted.\\n\\nChoose [Cancel] to Stop, [OK] to proceed.\\n', 'wp-activity'); ?> ');if(check==false) return false;" /> <br /><span class="activity_warning"><?php _e('Warning : cleaning activity table erase all activity logs.', 'wp-activity'); ?> </span> </form> </td> </tr><tr> <th><?php _e('Uninstall plugin', 'wp-activity'); ?> : </th> <td> <form name="act_form_uninst" method="post"> <?php if (function_exists('wp_nonce_field')) { wp_nonce_field('wp-activity-uninst', 'act_admin_uninst'); } ?> <input type="submit" class="button" name="act-uninst" value="<?php _e('Uninstall plugin', 'wp-activity'); ?> " onclick="javascript:check=confirm('<?php _e('Uninstall plugin ? Settings and activity logs will be deleted.\\n\\nChoose [Cancel] to Stop, [OK] to proceed.\\n', 'wp-activity'); ?> ');if(check==false) return false;" /> <br /><span class="activity_warning"><?php _e('Warning : This will delete settings and activity table.', 'wp-activity'); ?> </span> </form> </td> </tr> </table> </div><!-- End act_reset --> </div><!-- End slider tabs --> </div> <?php } ?> <br /> <h4 id="act_credits"><?php echo sprintf(__('WP-Activity is a plugin by <a href="http://www.driczone.net">Dric</a> and upgraded by <a href="https://profiles.wordpress.org/madvic/">madvic</a>. Version <strong>%s</strong>.', 'wp-activity'), $act_plugin_version); ?> </h4> </div> <?php }
function act_install() { global $wpdb, $act_plugin_version, $options_act; wp_schedule_event(time(), 'daily', 'act_cron_daily'); require_once ABSPATH . 'wp-admin/includes/upgrade.php'; $table = $wpdb->prefix . "activity"; $act_structure = "CREATE TABLE `" . $table . "` (\n `id` int(9) NOT NULL auto_increment,\n `user_id` bigint(20) NOT NULL,\n `act_type` varchar(20) NOT NULL,\n `act_date` datetime default NULL,\n `act_params` text,\n UNIQUE KEY `id` (`id`),\n KEY `user_id` (`user_id`),\n KEY `act_date` (`act_date`)\n );"; dbDelta($act_structure); $new_options_act['act_prune'] = '5000'; $new_options_act['act_feed_display'] = false; $new_options_act['act_date_format'] = 'yyyy/mm/dd'; $new_options_act['act_date_relative'] = true; $new_options_act['act_connect'] = true; $new_options_act['act_profiles'] = true; $new_options_act['act_posts'] = true; $new_options_act['act_comments'] = true; $new_options_act['act_links'] = true; $new_options_act['act_feed_connect'] = false; $new_options_act['act_feed_profiles'] = true; $new_options_act['act_feed_posts'] = true; $new_options_act['act_feed_comments'] = true; $new_options_act['act_feed_links'] = true; $new_options_act['act_icons'] = 'g'; $new_options_act['act_old'] = true; $new_options_act['act_prevent_priv'] = false; $new_options_act['act_log_failures'] = false; $new_options_act['act_author_path'] = 'author'; $new_options_act['act_blacklist_on'] = false; $new_options_act['act_auto_bl'] = false; $new_options_act['act_auto_bl_n'] = '5'; $new_options_act['act_bl_wplog'] = true; $new_options_act['act_refresh'] = false; $new_options_act['act_r_interval'] = '1800'; $new_options_act['act_version'] = $act_plugin_version; add_option('act_settings', $new_options_act); if ($options_act['act_version'] != $act_plugin_version) { act_desactive(); if (version_compare($options_act['act_version'], '1.4', '<')) { $options_act['act_author_path'] = 'author'; } if (version_compare($options_act['act_version'], '1.7', '<')) { $options_act['act_blacklist_on'] = false; $options_act['act_bl_wplog'] = true; } if (version_compare($options_act['act_version'], '1.8', '<')) { $options_act['act_auto_bl'] = false; $options_act['act_auto_bl_n'] = '5'; } if (version_compare($options_act['act_version'], '2.0', '<')) { $options_act['act_refresh'] = false; $options_act['act_r_interval'] = '1800'; } $options_act['act_version'] = $act_plugin_version; update_option('act_settings', $options_act); } flush_rewrite_rules(); }