Changeset 2769111
- Timestamp:
- 08/10/2022 09:06:06 PM (4 years ago)
- Location:
- sackson-web-data/trunk
- Files:
-
- 3 edited
-
README.txt (modified) (2 diffs)
-
includes/class-sacksonweb-data-helper.php (modified) (3 diffs)
-
sacksonweb-data.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sackson-web-data/trunk/README.txt
r2763240 r2769111 5 5 Requires at least: 3.0.1 6 6 Tested up to: 6.0 7 Stable tag: 1.1. 67 Stable tag: 1.1.7 8 8 Requires PHP: 7.0 9 9 License: GPLv2 or later … … 51 51 == Changelog == 52 52 53 = 1.1.7 = 54 * Added an extra check to make sure the simple history table exists as its expected to be named. 55 53 56 = 1.1.6 = 54 57 * 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 146 146 $this->getFileSystemItems (); 147 147 $this->getSimpleHistoryLastLoginData(); 148 $this->getUserData(); 148 149 } 149 150 … … 347 348 } 348 349 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 } 349 399 350 400 /** … … 359 409 } 360 410 361 362 411 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 382 439 383 440 } -
sackson-web-data/trunk/sacksonweb-data.php
r2763240 r2769111 10 10 * 11 11 * @link http://data.sacksonweb.com/author 12 * @since 1.1. 612 * @since 1.1.7 13 13 * @package Sacksonweb_Data 14 14 * … … 35 35 * 36 36 */ 37 define( 'SACKSONWEB_DATA_VERSION', '1.1. 6' );37 define( 'SACKSONWEB_DATA_VERSION', '1.1.7' ); 38 38 39 39 /**
Note: See TracChangeset
for help on using the changeset viewer.