Plugin Directory

Changeset 2964147


Ignore:
Timestamp:
09/07/2023 01:58:25 PM (3 years ago)
Author:
esselinknu
Message:

2.83

  • Extra data added to Collector
  • Edit LiteSpeed ESI mode
Location:
esselinknu-settings/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • esselinknu-settings/trunk/esselink-nu-settings.php

    r2940273 r2964147  
    44 * Plugin URI: http://www.esselink.nu
    55 * Description: Settings plugin for custom WP configuration for Esselink.nu WP websites
    6  * Version: 2.82
     6 * Version: 2.83
    77 * Author: Esselink.nu
    88 * Author URI: http://www.esselink.nu
    99**/
    10 $esselink_nu_settings_verson = 2.82;
     10$esselink_nu_settings_verson = 2.83;
    1111
    1212$esselink_nu_server_hosts = array('web02.esselink.nu', 'web03.esselink.nu', 'web04.esselink.nu');
  • esselinknu-settings/trunk/includes/admin-settings.php

    r2900100 r2964147  
    195195                    update_option( 'esselink_nu_settings_disable_xmlrpc', checkBoolean($_POST['esselink_nu_settings_disable_xmlrpc']), 'true' );
    196196                    update_option( 'esselink_nu_settings_litespeed_enable_guest', checkBoolean($_POST['esselink_nu_settings_litespeed_enable_guest']), 'true' );
     197                    update_option( 'esselink_nu_settings_litespeed_enable_esi', checkBoolean($_POST['esselink_nu_settings_litespeed_enable_esi']), 'true' );
    197198                   
    198199                    update_option( 'esselink_nu_settings_vc_style', checkBoolean($_POST['esselink_nu_settings_vc_style']), 'true' );
     
    717718                                            </fieldset>
    718719                                        </td>
     720                                    </tr>                   
     721                                    <tr valign="top">
     722                                        <th scope="row">
     723                                            <label for="esselink_nu_settings_litespeed_enable_esi">Force LiteSpeed ESI mode</label>
     724                                        </th>
     725                                        <td>
     726                                            <fieldset>
     727                                                <legend class="screen-reader-text">
     728                                                    <span>Force LiteSpeed ESI mode</span>
     729                                                </legend>
     730                                                <label for="esselink_nu_settings_litespeed_enable_esi">
     731                                                    <input name="esselink_nu_settings_litespeed_enable_esi" type="checkbox" <?= (get_option('esselink_nu_settings_litespeed_enable_esi')=='true') ? "checked" : "" ?> id="esselink_nu_settings_litespeed_enable_esi" value="true">Yes
     732                                                </label>
     733                                            </fieldset>
     734                                        </td>
    719735                                    </tr>                           
    720736                                </tbody>
  • esselinknu-settings/trunk/includes/basic-settings.php

    r2900863 r2964147  
    273273
    274274// Litespeed custom config
    275 if(get_option('litespeed.conf.esi') == false)
    276 {
    277     update_option( 'litespeed.conf.esi', 1 );
    278    
    279     $esinonce = unserialize('a:4:{i:0;s:11:"stats_nonce";i:1;s:15:"subscribe_nonce";i:2;s:7:"wp_rest";i:3;s:6:"wpcf7*";}');
    280     update_option('litespeed.conf.esi-nonce', $esinonce);   
     275if(get_option('esselink_nu_settings_litespeed_enable_esi') == false)
     276    add_option( 'esselink_nu_settings_litespeed_enable_esi', 'true', '', 'yes' );
     277
     278if(get_option('esselink_nu_settings_litespeed_enable_esi') != false && get_option('esselink_nu_settings_litespeed_enable_esi') == "true")
     279{
     280    if(get_option('litespeed.conf.esi') == false)
     281    {
     282        update_option( 'litespeed.conf.esi', 1 );
     283       
     284        $esinonce = unserialize('a:4:{i:0;s:11:"stats_nonce";i:1;s:15:"subscribe_nonce";i:2;s:7:"wp_rest";i:3;s:6:"wpcf7*";}');
     285        update_option('litespeed.conf.esi-nonce', $esinonce);   
     286    }
    281287}
    282288
  • esselinknu-settings/trunk/includes/wp-collector.php

    r2940273 r2964147  
    324324add_action('esselink_nu_settings_wp_collector_cronjob_event', 'esselink_nu_settings_wp_collector_cronjob_action');
    325325
     326//add_action('admin_post_wp_collector_check_data', 'esselink_nu_settings_wp_collector_cronjob_action'); // added by martijn 30-8-2023
     327
    326328
    327329function esselink_nu_settings_wp_collector_cronjob_deactivate() {   
     
    342344    $data = array();
    343345
     346    /* added by martijn 7-8-2023
     347    Oudste document / pagina in WP (voor leeftijd indicatie)
     348         Ouder dan 3 jaar
     349    Laatst gewijzigd document (activiteits indicatie)
     350    Laatste activiteit afgelopen 6 maanden
     351    Laatste inlog Tussen afgelopen 2 maand en afgelopen jaar                                                V -> added by martijn 8-8-2023
     352    Contactformulier plugin activiteit - recaptcha check Activiteit afgelopen maand
     353
     354    Bezoekersaantaantallen meten
     355    Wanneer aan eerste 4 voorwaarden wordt voldaan gaan we aantallen bijhouden
     356
     357    WP versie                                                                               V
     358    PHP versie                                                                              V
     359    Aantal actieve plugins (naam + versie) (indicatie voor update of vernieuwen)            V -> oppakken bij andere plugin
     360    Actief thema                                                                            V
     361    Aantal gepubliceerde pagina's                                                           V -> oppakken bij andere plugin
     362
     363    Woocommerce aantal orders vorige maand
     364    Woocommerce aantal producten in webshop
     365
     366    */
     367
    344368    $data["siteurl"] = get_option("siteurl");
    345369    $data["admin_email"] = get_option("admin_email");
     
    347371    $data["template"] = wp_get_theme()->Name;
    348372    $data["wpversion"] = $wp_version;
    349    
     373    $data["phpversion"] = phpversion();                                         // added by martijn 7-8-2023
     374    $data["last_login"] = getlastLogin();                                       // added by martijn 8-8-2023
    350375   
    351376    $data["seo_bad"] = getSEOCount("BAD");
     
    356381   
    357382    $data["pagesposts"] = getPagesPostsCount();
     383    $data["plugins"]    = activePluginsOverview();                              // added by martijn 7-8-2023
     384    $data["pages"]      = getPostCount(array("page"), array("publish"));        // added by martijn 8-8-2023
     385   
     386    if ( class_exists( 'woocommerce' ) ) {                                      // added by martijn 8-8-2023                   
     387        $data["products"]   = getPostCount(array("product"));
     388        $data["orders"]     = getPostCount(array("shop_order"), array(), array("post_modified LIKE '". date("Y-m", strtotime("-1 months")) ."%'"));     
     389    }else{
     390        $data["products"]   = NULL;
     391        $data["orders"]     = NULL;
     392    }
     393
     394
     395    // get contact data
     396    $contact = array();
     397    if(class_exists( 'WPCF7' ) && class_exists( 'CF7DBPlugin' )){               // added by martijn 30-8-2023
     398        $contact["CF"]["amount"] = getContactFormSubmits();
     399        $options = get_option('wpcf7');
     400        $contact["CF"]["recaptcha"] = ((isset($options["recaptcha"]))?true:false);
     401    }
     402
     403    if(class_exists( 'GFForms' )){                                              // added by martijn 30-8-2023
     404        $gf_public_key = get_option('rg_gforms_captcha_public_key');
     405        $gf_private_key = get_option('rg_gforms_captcha_private_key');
     406        $contact["GF"]["amount"] = getGravityformsSubmit();
     407        $contact["GF"]["recaptcha"] = (((!empty($gf_public_key) && !empty($gf_private_key)))?true:false);
     408    }
     409
     410    $data["contact"] = (!empty($contact))?$contact:NULL;   
    358411   
    359412    // Varnish check
     
    392445    $data["config_hotlinking"] = ($aio_wp_security_configs["aiowps_prevent_hotlinking"] == 1 ? 1 : 0);
    393446
     447    if(isset($_GET["debug"])){ //added by martijn 5-9-2023
     448        echo "<pre>";
     449        var_dump($data);
     450        echo "<pre>";
     451        wp_die();
     452    }
     453
    394454    $myvars = 'data=' . json_encode($data);
    395455
     
    420480
    421481   
     482    return $wpdb->num_rows;
     483}
     484
     485function getPostCount($post_types = array(), $post_status = array(), $custom_where = array()){ // added by martijn 8-8-2023
     486    $where = array();
     487    if(!empty($post_types)){
     488        $where[] = "p.post_type in ('". implode("'", $post_types) ."')";
     489    }
     490   
     491    if(!empty($post_status)){
     492        $where[] = "p.post_status in ('". implode("'", $post_status) ."')";
     493    }
     494
     495    if(!empty($custom_where)){
     496        $where[] = array_merge($where, $custom_where);
     497    }
     498
     499    global $wpdb;
     500    $wpdb->get_results("SELECT ID from {$wpdb->prefix}posts AS p".  ((!empty($where))?" WHERE ". implode(' AND ', $where):''));
    422501    return $wpdb->num_rows;
    423502}
     
    506585}
    507586
    508 
     587function activePluginsOverview() { // added by martijn 7-8-2023
     588
     589    // Get all plugins
     590    include_once( 'wp-admin/includes/plugin.php' );
     591    $all_plugins = get_plugins();
     592
     593    // Get active plugins
     594    $active_plugins = get_option('active_plugins');
     595
     596    // Assemble array of name, version, and whether plugin is active (boolean)
     597    foreach ( $all_plugins as $key => $value ) {
     598        $is_active = ( in_array( $key, $active_plugins ) ) ? true : false;
     599        if($is_active){
     600            $plugins[ $key ] = array(
     601                'name'    => $value['Name'],
     602                'version' => $value['Version'],
     603                'active'  => $is_active,
     604            );
     605        }
     606    }
     607
     608    return $plugins;
     609}
     610
     611function getlastLogin($type = 'month'){ // added by martijn 7-8-2023
     612    global $wpdb;
     613
     614    $results = $wpdb->get_results("
     615        SELECT user_id, meta_value as 'session_tokens'
     616        FROM $wpdb->usermeta
     617        WHERE `meta_key` = 'session_tokens'
     618    ");
     619
     620    // added by martijn 8-8-2023
     621    $max_time = strtotime('-1 years');
     622    $min_time = strtotime('-2 months');
     623
     624    $time = 0;
     625    foreach($results as $user){
     626        $session = unserialize($user->session_tokens);
     627
     628        if(($session["login"] >= $min_time && $session["login"] <= $max_time) && ($time > $session["login"] || $time == 0)){ // added by martijn 8-8-2023
     629            $time = $session["login"]; 
     630        }
     631    }
     632
     633    if($time > 0){
     634        return date("d-m-Y", $time);
     635    }else{
     636        return 0;
     637    }
     638}
     639
     640function getContactFormSubmits(){   // added by martijn 30-8-2023
     641    global $wpdb;
     642    $table = $wpdb->prefix. 'cf7dbplugin_st';
     643    $then = strtotime("-1 months");
     644    $now = strtotime("now");
     645    $contact_form = $wpdb->get_results(
     646        $wpdb->prepare(
     647            "
     648                SELECT *
     649                FROM {$table}
     650                WHERE submit_time BETWEEN %s AND %s
     651            ",
     652            array($then, $now)
     653        )
     654        , ARRAY_A
     655    ); 
     656    return count($contact_form);
     657}
     658
     659function getGravityformsSubmit($form = 0, $start = "", $end = ""){  // added by martijn 30-8-2023
     660    $form_ids = 0;
     661    $search_criteria = array(
     662        'status'        => 'active',
     663        'start_date'    => date("Y-m-d", strtotime("-1 months")),
     664        'end_date'      => date("Y-m-d"),
     665    );
     666
     667    return count(GFAPI::get_entry_ids( $form_ids, $search_criteria ));
     668}
  • esselinknu-settings/trunk/readme.txt

    r2940273 r2964147  
    184184= 2.82 =
    185185* Bugfix
    186 
     186= 2.83 =
     187* Extra data added to Collector
     188* Edit LiteSpeed ESI mode
    187189
    188190== Upgrade Notice ==
Note: See TracChangeset for help on using the changeset viewer.