Plugin Directory

Changeset 2769111


Ignore:
Timestamp:
08/10/2022 09:06:06 PM (4 years ago)
Author:
ehops32
Message:

1.1.7

  • Added an extra check to make sure the simple history table exists as its expected to be named.
Location:
sackson-web-data/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sackson-web-data/trunk/README.txt

    r2763240 r2769111  
    55Requires at least: 3.0.1
    66Tested up to: 6.0
    7 Stable tag: 1.1.6
     7Stable tag: 1.1.7
    88Requires PHP: 7.0
    99License: GPLv2 or later
     
    5151== Changelog ==
    5252
     53= 1.1.7 =
     54* Added an extra check to make sure the simple history table exists as its expected to be named.
     55
    5356= 1.1.6 =
    5457* Checks if the simple history plugin is installed. If so, looks at the last few accounts that have logged into the website.
  • sackson-web-data/trunk/includes/class-sacksonweb-data-helper.php

    r2763240 r2769111  
    146146        $this->getFileSystemItems ();
    147147        $this->getSimpleHistoryLastLoginData();
     148        $this->getUserData();
    148149    }
    149150   
     
    347348    }
    348349
     350    function getUserData()
     351    {
     352        $DBRecord = array();
     353        $args = array(
     354            /*'role'    => 'Subscriber',*/
     355            'orderby' => 'last_name',
     356            'order'   => 'ASC'
     357        );
     358        $users = get_users( $args );
     359        $i=0;
     360        foreach ( $users as $user )
     361        {
     362            //$DBRecord[$i]['role']           = "Subscriber";
     363            $DBRecord[$i]['WPId']           = $user->ID;
     364            $DBRecord[$i]['FirstName']      = $user->first_name;
     365            $DBRecord[$i]['LastName']       = $user->last_name;
     366            $DBRecord[$i]['RegisteredDate'] = $user->user_registered;
     367            $DBRecord[$i]['Email']          = $user->user_email;
     368
     369            //$UserData                       = get_user_meta( $user->ID );
     370            // $DBRecord[$i]['Company']        = $UserData['billing_company'][0];        // $DBRecord[$i]['Address']        = $UserData['billing_address_1'][0];        // $DBRecord[$i]['City']           = $UserData['billing_city'][0];
     371            // $DBRecord[$i]['State']          = $UserData['billing_state'][0];        // $DBRecord[$i]['PostCode']       = $UserData['billing_postcode'][0];        // $DBRecord[$i]['Country']        = $UserData['billing_country'][0];
     372            // $DBRecord[$i]['Phone']          = $UserData['billing_phone'][0];
     373            $i++;
     374        }
     375        $this->collected_data['user_list'] =  json_encode($DBRecord);
     376    }
     377
     378    /**
     379     *
     380     */
     381    function doAllTheseDatabaseTablesExist($table_names = array())
     382    {
     383        global $wpdb;
     384        $find_count = 0;
     385        $number_of_tables_to_find = count($table_names);
     386        foreach ($wpdb->tables('all') as $table_name => $table_name_with_prefix)
     387        {
     388            if ( in_array($table_name, $table_names))
     389            {
     390                $find_count = $find_count + 1;
     391            }
     392            if ( in_array($table_name_with_prefix, $table_names))
     393            {
     394                $find_count = $find_count + 1;
     395            }           
     396        }
     397        return $find_count == $number_of_tables_to_find ? true : false;
     398    }
    349399
    350400    /**
     
    359409        }
    360410
    361 
    362411        global $wpdb;
    363         /*
    364             FROM `wp_vmck51qx8n_simple_history` sh
    365             JOIN wp_vmck51qx8n_simple_history_contexts shc
    366         */
    367         $query = "SELECT sh.date, shc.value
    368                     FROM `{$wpdb->prefix}simple_history` sh
    369                     JOIN {$wpdb->prefix}simple_history_contexts shc
    370                       ON sh.id = shc.history_id
    371                     WHERE shc.history_id >= ((SELECT MAX(shc.history_id) FROM wp_vmck51qx8n_simple_history) - 10) AND shc.key = 'user_login'
    372         ";
    373 
    374         $rows = $wpdb->get_results($query);
    375         $last_logins = array();
    376         foreach ($rows as $row)
    377         {
    378             $last_logins[] = array($row->date, $row->value);
    379         }
    380         $this->collected_data['last_logins'] = json_encode($last_logins);
    381     }
     412
     413        $simple_history_table = $wpdb->prefix . 'simple_history';
     414        $simple_history_context_table = $wpdb->prefix . 'simple_history_contexts';
     415
     416        if ( $this->doAllTheseDatabaseTablesExist(array($simple_history_context_table, $simple_history_table)) )
     417        {       
     418            /*
     419                FROM `wp_vmck51qx8n_simple_history` sh
     420                JOIN wp_vmck51qx8n_simple_history_contexts shc
     421            */
     422            $query = "SELECT sh.date, shc.value
     423                        FROM `{$wpdb->prefix}simple_history` sh
     424                        JOIN {$wpdb->prefix}simple_history_contexts shc
     425                        ON sh.id = shc.history_id
     426                        WHERE shc.history_id >= ((SELECT MAX(shc.history_id) FROM {$wpdb->prefix}simple_history) - 10) AND shc.key = 'user_login'
     427            ";
     428
     429            $rows = $wpdb->get_results($query);
     430            $last_logins = array();
     431            foreach ($rows as $row)
     432            {
     433                $last_logins[] = array($row->date, $row->value);
     434            }
     435            $this->collected_data['last_logins'] = json_encode($last_logins);
     436        }
     437    }
     438
    382439
    383440}
  • sackson-web-data/trunk/sacksonweb-data.php

    r2763240 r2769111  
    1010 *
    1111 * @link              http://data.sacksonweb.com/author
    12  * @since             1.1.6
     12 * @since             1.1.7
    1313 * @package           Sacksonweb_Data
    1414 *
     
    3535 *
    3636 */
    37 define( 'SACKSONWEB_DATA_VERSION', '1.1.6' );
     37define( 'SACKSONWEB_DATA_VERSION', '1.1.7' );
    3838
    3939/**
Note: See TracChangeset for help on using the changeset viewer.