changes
This commit is contained in:
140
plugin-file/all-in-one-wp-migration/lib/vendor/servmask/database/class-ai1wm-database-mysql.php
vendored
Normal file
140
plugin-file/all-in-one-wp-migration/lib/vendor/servmask/database/class-ai1wm-database-mysql.php
vendored
Normal file
@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
class Ai1wm_Database_Mysql extends Ai1wm_Database {
|
||||
|
||||
/**
|
||||
* Run MySQL query
|
||||
*
|
||||
* @param string $input SQL query
|
||||
* @return mixed
|
||||
*/
|
||||
public function query( $input ) {
|
||||
if ( ! ( $result = mysql_query( $input, $this->wpdb->dbh ) ) ) {
|
||||
$mysql_errno = 0;
|
||||
|
||||
// Get MySQL error code
|
||||
if ( ! empty( $this->wpdb->dbh ) ) {
|
||||
if ( is_resource( $this->wpdb->dbh ) ) {
|
||||
$mysql_errno = mysql_errno( $this->wpdb->dbh );
|
||||
} else {
|
||||
$mysql_errno = 2006;
|
||||
}
|
||||
}
|
||||
|
||||
// MySQL server has gone away, try to reconnect
|
||||
if ( empty( $this->wpdb->dbh ) || 2006 === $mysql_errno ) {
|
||||
if ( ! $this->wpdb->check_connection( false ) ) {
|
||||
throw new Ai1wm_Database_Exception( __( 'Error reconnecting to the database. <a href="https://help.servmask.com/knowledgebase/mysql-error-reconnecting/" target="_blank">Technical details</a>', AI1WM_PLUGIN_NAME ), 503 );
|
||||
}
|
||||
|
||||
$result = mysql_query( $input, $this->wpdb->dbh );
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape string input for mysql query
|
||||
*
|
||||
* @param string $input String to escape
|
||||
* @return string
|
||||
*/
|
||||
public function escape( $input ) {
|
||||
return mysql_real_escape_string( $input, $this->wpdb->dbh );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the error code for the most recent function call
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function errno() {
|
||||
return mysql_errno( $this->wpdb->dbh );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string description of the last error
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function error() {
|
||||
return mysql_error( $this->wpdb->dbh );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return server version
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function version() {
|
||||
return mysql_get_server_info( $this->wpdb->dbh );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the result from MySQL query as associative array
|
||||
*
|
||||
* @param resource $result MySQL resource
|
||||
* @return array
|
||||
*/
|
||||
public function fetch_assoc( $result ) {
|
||||
return mysql_fetch_assoc( $result );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the result from MySQL query as row
|
||||
*
|
||||
* @param resource $result MySQL resource
|
||||
* @return array
|
||||
*/
|
||||
public function fetch_row( $result ) {
|
||||
return mysql_fetch_row( $result );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number for rows from MySQL results
|
||||
*
|
||||
* @param resource $result MySQL resource
|
||||
* @return integer
|
||||
*/
|
||||
public function num_rows( $result ) {
|
||||
return mysql_num_rows( $result );
|
||||
}
|
||||
|
||||
/**
|
||||
* Free MySQL result memory
|
||||
*
|
||||
* @param resource $result MySQL resource
|
||||
* @return boolean
|
||||
*/
|
||||
public function free_result( $result ) {
|
||||
return mysql_free_result( $result );
|
||||
}
|
||||
}
|
145
plugin-file/all-in-one-wp-migration/lib/vendor/servmask/database/class-ai1wm-database-mysqli.php
vendored
Normal file
145
plugin-file/all-in-one-wp-migration/lib/vendor/servmask/database/class-ai1wm-database-mysqli.php
vendored
Normal file
@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
class Ai1wm_Database_Mysqli extends Ai1wm_Database {
|
||||
|
||||
/**
|
||||
* Run MySQL query
|
||||
*
|
||||
* @param string $input SQL query
|
||||
* @return mixed
|
||||
*/
|
||||
public function query( $input ) {
|
||||
if ( ! mysqli_real_query( $this->wpdb->dbh, $input ) ) {
|
||||
$mysqli_errno = 0;
|
||||
|
||||
// Get MySQL error code
|
||||
if ( ! empty( $this->wpdb->dbh ) ) {
|
||||
if ( $this->wpdb->dbh instanceof mysqli ) {
|
||||
$mysqli_errno = mysqli_errno( $this->wpdb->dbh );
|
||||
} else {
|
||||
$mysqli_errno = 2006;
|
||||
}
|
||||
}
|
||||
|
||||
// MySQL server has gone away, try to reconnect
|
||||
if ( empty( $this->wpdb->dbh ) || 2006 === $mysqli_errno ) {
|
||||
if ( ! $this->wpdb->check_connection( false ) ) {
|
||||
throw new Ai1wm_Database_Exception( __( 'Error reconnecting to the database. <a href="https://help.servmask.com/knowledgebase/mysql-error-reconnecting/" target="_blank">Technical details</a>', AI1WM_PLUGIN_NAME ), 503 );
|
||||
}
|
||||
|
||||
mysqli_real_query( $this->wpdb->dbh, $input );
|
||||
}
|
||||
}
|
||||
|
||||
// Copy results from the internal mysqlnd buffer into the PHP variables fetched
|
||||
if ( defined( 'MYSQLI_STORE_RESULT_COPY_DATA' ) ) {
|
||||
return mysqli_store_result( $this->wpdb->dbh, MYSQLI_STORE_RESULT_COPY_DATA );
|
||||
}
|
||||
|
||||
return mysqli_store_result( $this->wpdb->dbh );
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape string input for mysql query
|
||||
*
|
||||
* @param string $input String to escape
|
||||
* @return string
|
||||
*/
|
||||
public function escape( $input ) {
|
||||
return mysqli_real_escape_string( $this->wpdb->dbh, $input );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the error code for the most recent function call
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function errno() {
|
||||
return mysqli_errno( $this->wpdb->dbh );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a string description of the last error
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function error() {
|
||||
return mysqli_error( $this->wpdb->dbh );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return server version
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function version() {
|
||||
return mysqli_get_server_info( $this->wpdb->dbh );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the result from MySQL query as associative array
|
||||
*
|
||||
* @param resource $result MySQL resource
|
||||
* @return array
|
||||
*/
|
||||
public function fetch_assoc( $result ) {
|
||||
return mysqli_fetch_assoc( $result );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the result from MySQL query as row
|
||||
*
|
||||
* @param resource $result MySQL resource
|
||||
* @return array
|
||||
*/
|
||||
public function fetch_row( $result ) {
|
||||
return mysqli_fetch_row( $result );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number for rows from MySQL results
|
||||
*
|
||||
* @param resource $result MySQL resource
|
||||
* @return integer
|
||||
*/
|
||||
public function num_rows( $result ) {
|
||||
return mysqli_num_rows( $result );
|
||||
}
|
||||
|
||||
/**
|
||||
* Free MySQL result memory
|
||||
*
|
||||
* @param resource $result MySQL resource
|
||||
* @return boolean
|
||||
*/
|
||||
public function free_result( $result ) {
|
||||
return mysqli_free_result( $result );
|
||||
}
|
||||
}
|
184
plugin-file/all-in-one-wp-migration/lib/vendor/servmask/database/class-ai1wm-database-utility.php
vendored
Normal file
184
plugin-file/all-in-one-wp-migration/lib/vendor/servmask/database/class-ai1wm-database-utility.php
vendored
Normal file
@ -0,0 +1,184 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2014-2023 ServMask Inc.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗
|
||||
* ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝
|
||||
* ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝
|
||||
* ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗
|
||||
* ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗
|
||||
* ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Kangaroos cannot jump here' );
|
||||
}
|
||||
|
||||
class Ai1wm_Database_Utility {
|
||||
|
||||
/**
|
||||
* Get MySQLClient to be used for DB manipulation
|
||||
*
|
||||
* @return Ai1wm_Database
|
||||
*/
|
||||
public static function create_client() {
|
||||
global $wpdb;
|
||||
|
||||
if ( PHP_MAJOR_VERSION >= 7 ) {
|
||||
return new Ai1wm_Database_Mysqli( $wpdb );
|
||||
}
|
||||
|
||||
if ( empty( $wpdb->use_mysqli ) ) {
|
||||
return new Ai1wm_Database_Mysql( $wpdb );
|
||||
}
|
||||
|
||||
return new Ai1wm_Database_Mysqli( $wpdb );
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace all occurrences of the search string with the replacement string.
|
||||
* This function is case-sensitive.
|
||||
*
|
||||
* @param array $from List of string we're looking to replace.
|
||||
* @param array $to What we want it to be replaced with.
|
||||
* @param string $data Data to replace.
|
||||
* @return mixed The original string with all elements replaced as needed.
|
||||
*/
|
||||
public static function replace_values( $from = array(), $to = array(), $data = '' ) {
|
||||
if ( ! empty( $from ) && ! empty( $to ) ) {
|
||||
return strtr( $data, array_combine( $from, $to ) );
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Take a serialized array and unserialize it replacing elements as needed and
|
||||
* unserializing any subordinate arrays and performing the replace on those too.
|
||||
* This function is case-sensitive.
|
||||
*
|
||||
* @param array $from List of string we're looking to replace.
|
||||
* @param array $to What we want it to be replaced with.
|
||||
* @param mixed $data Used to pass any subordinate arrays back to in.
|
||||
* @param bool $serialized Does the array passed via $data need serializing.
|
||||
* @return mixed The original array with all elements replaced as needed.
|
||||
*/
|
||||
public static function replace_serialized_values( $from = array(), $to = array(), $data = '', $serialized = false ) {
|
||||
try {
|
||||
|
||||
// Some unserialized data cannot be re-serialized eg. SimpleXMLElements
|
||||
if ( is_serialized( $data ) && ( $unserialized = @unserialize( $data ) ) !== false ) {
|
||||
$data = self::replace_serialized_values( $from, $to, $unserialized, true );
|
||||
} elseif ( is_array( $data ) ) {
|
||||
$tmp = array();
|
||||
foreach ( $data as $key => $value ) {
|
||||
$tmp[ $key ] = self::replace_serialized_values( $from, $to, $value, false );
|
||||
}
|
||||
|
||||
$data = $tmp;
|
||||
unset( $tmp );
|
||||
} elseif ( is_object( $data ) ) {
|
||||
if ( ! ( $data instanceof __PHP_Incomplete_Class ) ) {
|
||||
$tmp = $data;
|
||||
$props = get_object_vars( $data );
|
||||
foreach ( $props as $key => $value ) {
|
||||
if ( ! empty( $tmp->$key ) ) {
|
||||
$tmp->$key = self::replace_serialized_values( $from, $to, $value, false );
|
||||
}
|
||||
}
|
||||
|
||||
$data = $tmp;
|
||||
unset( $tmp );
|
||||
}
|
||||
} else {
|
||||
if ( is_string( $data ) ) {
|
||||
if ( ! empty( $from ) && ! empty( $to ) ) {
|
||||
$data = strtr( $data, array_combine( $from, $to ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $serialized ) {
|
||||
return serialize( $data );
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape MySQL special characters
|
||||
*
|
||||
* @param string $data Data to escape
|
||||
* @return string
|
||||
*/
|
||||
public static function escape_mysql( $data ) {
|
||||
return strtr(
|
||||
$data,
|
||||
array_combine(
|
||||
array( "\x00", "\n", "\r", '\\', "'", '"', "\x1a" ),
|
||||
array( '\\0', '\\n', '\\r', '\\\\', "\\'", '\\"', '\\Z' )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unescape MySQL special characters
|
||||
*
|
||||
* @param string $data Data to unescape
|
||||
* @return string
|
||||
*/
|
||||
public static function unescape_mysql( $data ) {
|
||||
return strtr(
|
||||
$data,
|
||||
array_combine(
|
||||
array( '\\0', '\\n', '\\r', '\\\\', "\\'", '\\"', '\\Z' ),
|
||||
array( "\x00", "\n", "\r", '\\', "'", '"', "\x1a" )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode base64 characters
|
||||
*
|
||||
* @param string $data Data to encode
|
||||
* @return string
|
||||
*/
|
||||
public static function base64_encode( $data ) {
|
||||
return base64_encode( $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode base64 characters
|
||||
*
|
||||
* @param string $data Data to decode
|
||||
* @return string
|
||||
*/
|
||||
public static function base64_decode( $data ) {
|
||||
return base64_decode( $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate base64 data
|
||||
*
|
||||
* @param string $data Data to validate
|
||||
* @return boolean
|
||||
*/
|
||||
public static function base64_validate( $data ) {
|
||||
return base64_encode( base64_decode( $data ) ) === $data;
|
||||
}
|
||||
}
|
2129
plugin-file/all-in-one-wp-migration/lib/vendor/servmask/database/class-ai1wm-database.php
vendored
Normal file
2129
plugin-file/all-in-one-wp-migration/lib/vendor/servmask/database/class-ai1wm-database.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user