\MainWP\DashboardMainWP_DB_Monitoring

Class MainWP_DB_Monitoring

Summary

Methods
Properties
Constants
instance()
get_option_view()
get_connected_websites()
get_disconnected_websites()
get_websites_count()
get_website_option()
get_website_options_array()
update_website_option()
get_websites_by_user_id()
get_sql_websites()
get_sql_websites_to_check_status()
get_sql_websites_by_user_id()
get_sql_websites_for_current_user()
get_websites_for_current_user()
get_sql_search_websites_for_current_user()
get_sql_where_allow_access_sites()
get_sql_where_allow_groups()
get_website_by_id()
get_sql_website_by_id()
get_websites_by_ids()
get_websites_by_group_ids()
get_websites_by_group_id()
get_sql_websites_by_group_id()
get_websites_by_group_name()
get_sql_websites_by_group_name()
get_wp_ip()
add_website()
remove_website()
update_website_values()
update_website_sync_values()
update_website()
get_websites_check_updates_count()
get_websites_count_where_dts_automatic_sync_smaller_then_start()
get_websites_last_automatic_sync()
get_websites_check_updates()
get_websites_stats_update_sql()
update_website_stats()
get_websites_by_url()
get_websites_offline_status_to_send_notice()
get_websites_to_notice_health_threshold()
get_websites_offline_check_status()
__construct()
get_my_sql_version()
get_row_result()
get_results_result()
query()
use_mysqli()
ping()
m_query()
fetch_object()
free_result()
data_seek()
fetch_array()
num_rows()
is_result()
insert_website_status()
purge_monitoring_records()
No public properties found
No constants found
test_connection()
table_name()
escape()
$table_prefix
$wpdb
N/A
No private methods found
$instance
N/A

Properties

$table_prefix

$table_prefix : string

Table prefix.

Type

string

$wpdb

$wpdb : mixed

WordPress Database.

Type

mixed — WordPress Database.

$instance

$instance : mixed

Private static variable to hold the single instance of the class.

Type

mixed — Default null

Methods

get_option_view()

get_option_view(array  $fields = array(), boolean  $default = true) : array

Get wp_options database table view.

Parameters

array $fields

Extra option fields.

boolean $default

Whether or not to get default option fields.

Returns

array —

wp_options view.

get_connected_websites()

get_connected_websites(array  $sites_ids = false) : array

Get connected child sites.

Parameters

array $sites_ids

Websites ids - option field.

Returns

array —

$connected_sites Array of connected sites.

get_disconnected_websites()

get_disconnected_websites(array  $sites_ids = false) : array

Get disconnected child sites.

Parameters

array $sites_ids

Websites ids - option field.

Returns

array —

$disc_sites Array of disonnected sites.

get_websites_count()

get_websites_count(null  $userId = null, boolean  $all_access = false) : integer

Get child site count.

Parameters

null $userId

Current user ID.

boolean $all_access

Check if user has access to all sites.

Returns

integer —

Child site count.

get_website_option()

get_website_option(array  $website, mixed  $option) : string|null

Get Child site wp_options database table.

Parameters

array $website

Child Site array.

mixed $option

Child Site wp_options table name.

Returns

string|null —

Database query result (as string), or null on failure.

get_website_options_array()

get_website_options_array(array  $website, mixed  $options) : string|null

Get child site options.

Parameters

array $website

Child site.

mixed $options

Child site options name.

Returns

string|null —

Database query result (as string), or null on failure.

update_website_option()

update_website_option(object  $website, mixed  $option, mixed  $value) 

Update child site options.

Parameters

object $website

Child site object.

mixed $option

Option to update.

mixed $value

Value to update with.

get_websites_by_user_id()

get_websites_by_user_id(integer  $userid, boolean  $selectgroups = false, null  $search_site = null, string  $orderBy = 'wp.url') : array|object|null

Get child sites by user ID.

Parameters

integer $userid

User ID.

boolean $selectgroups

Selected groups.

null $search_site

Site search field value.

string $orderBy

Order list by. Default: URL.

Returns

array|object|null —

Database query results or null on failer.

get_sql_websites()

get_sql_websites() : string

Get child sites.

Returns

string —

SQL string.

get_sql_websites_to_check_status()

get_sql_websites_to_check_status(integer  $last_check, integer  $count = 20) : string

Get child sites to run the status check process.

Parameters

integer $last_check

Time of the last check.

integer $count

Number of websites.

Returns

string —

SQL string.

get_sql_websites_by_user_id()

get_sql_websites_by_user_id(integer  $userid, boolean  $selectgroups = false, null  $search_site = null, string  $orderBy = 'wp.url', boolean  $offset = false, boolean  $rowcount = false) : object|null

Get child sites by user id via SQL.

Parameters

integer $userid

Given user ID.

boolean $selectgroups

Selected groups. Default: false.

null $search_site

Site search field value. Default: null.

string $orderBy

Order list by. Default: URL.

boolean $offset

Query offset. Default: false.

boolean $rowcount

Row count. Default: falese.

Returns

object|null —

Return database query or null on failure.

get_sql_websites_for_current_user()

get_sql_websites_for_current_user(boolean  $selectgroups = false, null  $search_site = null, string  $orderBy = 'wp.url', boolean  $offset = false, boolean  $rowcount = false, null  $extraWhere = null, boolean  $for_manager = false, mixed  $extra_view = array('favi_icon'), string  $is_staging = 'no') : object|null

Get SQL to get child sites for current user.

Parameters

boolean $selectgroups

Selected groups. Default: false.

null $search_site

Site search field value. Default: null.

string $orderBy

Order list by. Default: URL.

boolean $offset

Query offset. Default: false.

boolean $rowcount

Row count. Default: false.

null $extraWhere

Extra WHERE. Default: null.

boolean $for_manager

For role manager. Default: false.

mixed $extra_view

Extra view. Default favi_icon.

string $is_staging

yes|no Is child site a staging site.

Returns

object|null —

Database query results or null on failure.

get_websites_for_current_user()

get_websites_for_current_user(array  $params = array()) : array

Get child sites for current user.

Parameters

array $params

to get sites. Default: array().

Returns

array —

Results or null on failure.

get_sql_search_websites_for_current_user()

get_sql_search_websites_for_current_user(array  $params) : boolean|null

Get the child sites the current user has searched for.

Parameters

array $params

Query parameters.

Returns

boolean|null —

$qry Database query results or null on failure.

get_sql_where_allow_access_sites()

get_sql_where_allow_access_sites(string  $site_table_alias = '', string  $is_staging = 'no') : boolean|null

Get child sites where allowed access via SQL.

Parameters

string $site_table_alias

Child site table alias.

string $is_staging

yes|no Is child site a staging site.

Returns

boolean|null —

$_where Database query results or null on failure.

get_sql_where_allow_groups()

get_sql_where_allow_groups(string  $group_table_alias = '', string  $with_staging = 'no') : boolean|null

Get groupd where allowed access via SQL.

Parameters

string $group_table_alias

Child site table alias.

string $with_staging

yes|no Is child site a staging site.

Returns

boolean|null —

$_where Database query results or null on failer.

get_website_by_id()

get_website_by_id(integer  $id, array  $selectGroups = false, array  $fields = array()) : object|null

Get child site by id.

Parameters

integer $id

Child site ID.

array $selectGroups

Select groups.

array $fields

Get extra option fields.

Returns

object|null —

Database query results or null on failure.

get_sql_website_by_id()

get_sql_website_by_id(integer  $id, boolean  $selectGroups = false, mixed  $extra_view = array()) : object|null

Get child site by id via SQL.

Parameters

integer $id

Child site ID.

boolean $selectGroups

Selected groups.

mixed $extra_view

Extra view value.

Returns

object|null —

Database query result or null on failure.

get_websites_by_ids()

get_websites_by_ids(array  $ids, integer  $userId = null) : object|null

Method get_websites_by_ids()

Get child sites by child site IDs.

Parameters

array $ids

Child site IDs.

integer $userId

User ID.

Returns

object|null —

Database query result or null on failure.

get_websites_by_group_ids()

get_websites_by_group_ids(array  $ids, integer  $userId = null) : object|null

Get child sites by groups IDs.

Parameters

array $ids

Groups IDs.

integer $userId

User ID.

Returns

object|null —

Database query result or null on failure.

get_websites_by_group_id()

get_websites_by_group_id(integer  $id) : object|null

Get child sites by group ID.

Parameters

integer $id

Group ID.

Returns

object|null —

Database query result or null on failure.

get_sql_websites_by_group_id()

get_sql_websites_by_group_id(integer  $id, boolean  $selectgroups = false, string  $orderBy = 'wp.url', boolean  $offset = false, boolean  $rowcount = false, null  $where = null, null  $search_site = null) : object|null

Get child sites by group id via SQL.

Parameters

integer $id

Group ID.

boolean $selectgroups

Selected groups. Default: false.

string $orderBy

Order list by. Default: URL.

boolean $offset

Query offset. Default: false.

boolean $rowcount

Row count. Default: falese.

null $where

SQL WHERE value.

null $search_site

Site search field value. Default: null.

Returns

object|null —

Return database query or null on failure.

get_websites_by_group_name()

get_websites_by_group_name(integer  $userid, string  $groupname) : object|null

Get child sites by group name.

Parameters

integer $userid

Current user ID.

string $groupname

Group name.

Returns

object|null —

Database query result or null on failure.

get_sql_websites_by_group_name()

get_sql_websites_by_group_name(string  $groupname, integer  $userid = null) : object|null

Get child sites by group name.

Parameters

string $groupname

Group name.

integer $userid

Current user ID.

Returns

object|null —

Database query result or null on failure.

get_wp_ip()

get_wp_ip(integer  $wpid) : string|null

Get child site IP address.

Parameters

integer $wpid

Child site ID.

Returns

string|null —

Child site IP address or null on failure.

add_website()

add_website(integer  $userid, string  $name, string  $url, string  $admin, string  $pubkey, string  $privkey, mixed  $nossl, mixed  $nosslkey, array  $groupids, array  $groupnames, integer  $verifyCertificate = 1, string  $uniqueId = '', string  $http_user, string  $http_pass, integer  $sslVersion, integer  $wpe, integer  $isStaging) : integer|false

Add website to the MainWP Dashboard.

Parameters

integer $userid

Current user ID.

string $name

Child site name.

string $url

Child site URL.

string $admin

Child site administrator username.

string $pubkey

OpenSSL public key.

string $privkey

OpenSSL private key.

mixed $nossl

SSL suppoted connection.

mixed $nosslkey

SSL not supported connection key.

array $groupids

Group IDs.

array $groupnames

Group names.

integer $verifyCertificate

Whether or not to verify SSL Certificate.

string $uniqueId

Unique security ID.

string $http_user

HTTP Basic Authentication username.

string $http_pass

HTTP Basic Authentication password.

integer $sslVersion

SSL Version.

integer $wpe

Is it WP Engine hosted site.

integer $isStaging

Whether or not child site is staging site.

Returns

integer|false —

Child site ID or false on failure.

remove_website()

remove_website(integer  $websiteid) : integer|boolean

Remove child site from the MainWP Dashboard.

Parameters

integer $websiteid

Child site ID.

Returns

integer|boolean —

Return child site ID that was removed or false on failure.

update_website_values()

update_website_values(integer  $websiteid, array  $fields) : integer|boolean

Update child site db values.

Parameters

integer $websiteid

Child site ID.

array $fields

Database fields to update.

Returns

integer|boolean —

The number of rows updated, or false on error.

update_website_sync_values()

update_website_sync_values(integer  $websiteid, array  $fields) : integer|boolean

Update child site sync values.

Parameters

integer $websiteid

Child site ID.

array $fields

Database fields to update.

Returns

integer|boolean —

The number of rows updated, or false on error.

update_website()

update_website(integer  $websiteid, string  $url, integer  $userid, string  $name, string  $siteadmin, array  $groupids, array  $groupnames, string  $pluginDir, mixed  $maximumFileDescriptorsOverride, mixed  $maximumFileDescriptorsAuto, mixed  $maximumFileDescriptors, integer  $verifyCertificate = 1, mixed  $archiveFormat, string  $uniqueId = '', string  $http_user = null, string  $http_pass = null, integer  $sslVersion, integer  $disableChecking, integer  $checkInterval, boolean  $disableHealthChecking, integer  $healthThreshold, integer  $wpe) : boolean

Update child site.

Parameters

integer $websiteid

Website ID.

string $url

Child site URL.

integer $userid

Current user ID.

string $name

Child site name.

string $siteadmin

Child site administrator username.

array $groupids

Group IDs.

array $groupnames

Group Names.

string $pluginDir

Plugin directory.

mixed $maximumFileDescriptorsOverride

Overwrite the Maximum File Descriptors option.

mixed $maximumFileDescriptorsAuto

Auto set the Maximum File Descriptors option.

mixed $maximumFileDescriptors

Set the Maximum File Descriptors option.

integer $verifyCertificate

Whether or not to verify SSL Certificate.

mixed $archiveFormat

Backup archive formate.

string $uniqueId

Unique security ID.

string $http_user

HTTP Basic Authentication username.

string $http_pass

HTTP Basic Authentication password.

integer $sslVersion

SSL Version.

integer $disableChecking

Wether or not disable sites status checking.

integer $checkInterval

Status checking interval.

boolean $disableHealthChecking

Disable Site health threshold.

integer $healthThreshold

Site health threshold.

integer $wpe

Is it WP Engine hosted site.

Returns

boolean —

ture on success or false on failure.

get_websites_check_updates_count()

get_websites_check_updates_count(integer  $lasttime_start) : integer

Get websites check updates count.

Parameters

integer $lasttime_start

Lasttime start automatic update.

Returns

integer —

Child sites update count.

get_websites_count_where_dts_automatic_sync_smaller_then_start()

get_websites_count_where_dts_automatic_sync_smaller_then_start(integer  $lasttime_start) : integer

Get child site count where date & time Session sync is smaller then start.

Parameters

integer $lasttime_start

Last time start automatic.

Returns

integer —

Returned child site count.

get_websites_last_automatic_sync()

get_websites_last_automatic_sync() : string

Get child site last automatic sync date & time.

Returns

string —

Date and time of last automatic sync.

get_websites_check_updates()

get_websites_check_updates(integer  $limit, integer  $lasttime_start) : object|null

Get child sites check updates.

Parameters

integer $limit

Query limit.

integer $lasttime_start

Lasttime start automatic update.

Returns

object|null —

Database query result or null on failure.

get_websites_stats_update_sql()

get_websites_stats_update_sql() : object|null

Get website update stats via SQL.

Returns

object|null —

Database query result of null on failure.

update_website_stats()

update_website_stats(mixed  $websiteid, mixed  $statsUpdated) : \MainWP\Dashboard\(int|\MainWP\Dashboard\boolean)

Update child site statistics.

Update whether or not a child site has been updated.

Parameters

mixed $websiteid

Child site ID.

mixed $statsUpdated

Child site Update status.

Returns

\MainWP\Dashboard\(int|\MainWP\Dashboard\boolean) —

Number of rows effected in update or false on failure.

get_websites_by_url()

get_websites_by_url(string  $url) : object|null

Get child site by url.

Parameters

string $url

Child site URL.

Returns

object|null —

Database query result or null on failure.

get_websites_offline_status_to_send_notice()

get_websites_offline_status_to_send_notice() : array

Get websites offline status.

Returns

array —

Child site monitoring status.

get_websites_to_notice_health_threshold()

get_websites_to_notice_health_threshold(integer  $globalThreshold, integer  $count = 10) 

Method get_websites_to_notice_health_threshold()

Get websites to notice site health.

Parameters

integer $globalThreshold

Global site health threshold.

integer $count

Limit count.

get_websites_offline_check_status()

get_websites_offline_check_status() : array

Get websites offline status.

Returns

array —

Sites with offline status.

__construct()

__construct() 

MainWP_DB_Base constructor.

Run each time the class is called.

get_my_sql_version()

get_my_sql_version() : mixed

Method get_my_sql_version()

Get MySQL Version.

Returns

mixed —

MySQL vresion.

get_row_result()

get_row_result(mixed  $sql) : mixed

Method get_row_result()

Get row result.

Parameters

mixed $sql

SQL Query.

Returns

mixed —

null|Row

get_results_result()

get_results_result(mixed  $sql) : mixed

Method get_results_result()

Get Results of result.

Parameters

mixed $sql

SQL query.

Returns

mixed —

null|get_results()

query()

query(mixed  $sql) : mixed

Method query()

SQL Query.

Parameters

mixed $sql

SQL Query.

Returns

mixed —

false|$result.

use_mysqli()

use_mysqli() : boolean|self

Method use_mysqli()

Use MySQLi, Support old & new versions of WordPress (3.9+).

Returns

boolean|self —

false|$instance Instance of \mysqli

ping()

ping(mixed  $link) : mixed

Method ping()

Ping MySQLi.

Parameters

mixed $link

Query link.

Returns

mixed —

\mysqli_ping

m_query()

m_query(mixed  $query, mixed  $link) : mixed

Method m_query()

MySQLi m_query.

Parameters

mixed $query

Query params.

mixed $link

Query link.

Returns

mixed —

\mysqli_query

fetch_object()

fetch_object(mixed  $result) : boolean|mixed

Method fetch_object()

Fetch object.

Parameters

mixed $result

Query result.

Returns

boolean|mixed —

false|\mysqli_fetch_object

free_result()

free_result(mixed  $result) : boolean|mixed

Method free_result()

MySQLi free result.

Parameters

mixed $result

Query result.

Returns

boolean|mixed —

false|\mysqli_free_result

data_seek()

data_seek(mixed  $result, mixed  $offset) : boolean|mixed

Method data_seek()

MySQLi data seek.

Parameters

mixed $result

Query result.

mixed $offset

Query offset.

Returns

boolean|mixed —

false|\mysqli_data_seek

fetch_array()

fetch_array(mixed  $result, null  $result_type = null) : boolean|mixed

Method fetch_array()

MySQLi fetch array.

Parameters

mixed $result

Query result.

null $result_type

Query result type.

Returns

boolean|mixed —

false|\mysqli_fetch_array.

num_rows()

num_rows(mixed  $result) : boolean|mixed

Method num_rows()

MySQLi number of rows.

Parameters

mixed $result

Query result.

Returns

boolean|mixed —

false|\mysqli_num_rows.

is_result()

is_result(mixed  $result) : boolean|mixed

Method is_result()

Return instance of \mysqli_result

Parameters

mixed $result

Query result.

Returns

boolean|mixed —

false|\mysqli_result

insert_website_status()

insert_website_status(array  $fields) : integer

Method insert_website_status()

Insert website checking status.

Parameters

array $fields

fields to insert.

Returns

integer —

$insert_id False or inserted id.

purge_monitoring_records()

purge_monitoring_records() : void

Method purge_monitoring_records()

Purge monitoring records.

test_connection()

test_connection() 

Method test_connection()

Test db connection.

table_name()

table_name(mixed  $suffix, null  $tablePrefix = null) : string

Method table_name()

Create entire table name.

Parameters

mixed $suffix

Table suffix.

null $tablePrefix

Table prefix.

Returns

string —

Table name.

escape()

escape(mixed  $data) : mixed

Method escape()

Escape SQL Data.

Parameters

mixed $data

Data to escape.

Returns

mixed —

Escapped SQL Data.