JezK
Edit File: class.db.php
<?php use Duplicator\Libs\Snap\SnapOS; defined('ABSPATH') || defined('DUPXABSPATH') || exit; /** * Lightweight abstraction layer for common simple database routines * * Standard: PSR-2 * * @link http://www.php-fig.org/psr/psr-2 * * @package Duplicator * @subpackage classes/utilities * @copyright (c) 2017, Snapcreek LLC */ // Exit if accessed directly if (!defined('DUPLICATOR_VERSION')) { exit; } class DUP_DB extends wpdb { const BUILD_MODE_MYSQLDUMP = 'MYSQLDUMP'; const BUILD_MODE_PHP_SINGLE_THREAD = 'PHP'; const MAX_TABLE_COUNT_IN_PACKET = 100; public static $remove_placeholder_escape_exists = null; public static function init() { global $wpdb; self::$remove_placeholder_escape_exists = method_exists($wpdb, 'remove_placeholder_escape'); } /** * Get the requested MySQL system variable * * @param string $name The database variable name to lookup * * @return string the server variable to query for */ public static function getVariable($name) { global $wpdb; if (strlen($name)) { $query = $wpdb->prepare("SHOW VARIABLES LIKE %s", $name); $row = $wpdb->get_row($query, ARRAY_N); return isset($row[1]) ? $row[1] : null; } else { return null; } } /** * Return the value of lower_case_table_names * * @see https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_lower_case_table_names * * @return int */ public static function getLowerCaseTableNames() { if (($result = self::getVariable("lower_case_table_names")) === null) { if (SnapOS::isOSX()) { return 2; } elseif (SnapOS::isWindows()) { return 1; } else { return 0; } } return (int) $result; } /** * Gets the MySQL database version number * * @param bool $full True: Gets the full version * False: Gets only the numeric portion i.e. 5.5.6 or 10.1.2 (for MariaDB) * * @return false|string 0 on failure, version number on success */ public static function getVersion($full = false) { global $wpdb; if ($full) { $version = self::getVariable('version'); } else { $version = preg_replace('/[^0-9.].*/', '', self::getVariable('version')); } //Fall-back for servers that have restricted SQL for SHOW statement if (empty($version)) { $version = $wpdb->db_version(); } return empty($version) ? 0 : $version; } /** * Try to return the mysqldump path on Windows servers * * @return boolean|string */ public static function getWindowsMySqlDumpRealPath() { if (function_exists('php_ini_loaded_file')) { $get_php_ini_path = php_ini_loaded_file(); if (file_exists($get_php_ini_path)) { $search = array( dirname(dirname($get_php_ini_path)) . '/mysql/bin/mysqldump.exe', dirname(dirname(dirname($get_php_ini_path))) . '/mysql/bin/mysqldump.exe', dirname(dirname($get_php_ini_path)) . '/mysql/bin/mysqldump', dirname(dirname(dirname($get_php_ini_path))) . '/mysql/bin/mysqldump', ); foreach ($search as $mysqldump) { if (file_exists($mysqldump)) { return str_replace("\\", "/", $mysqldump); } } } } unset($search); unset($get_php_ini_path); return false; } /** * Returns the correct database build mode PHP, MYSQLDUMP, PHPCHUNKING * * @return string Returns a string with one of theses three values PHP, MYSQLDUMP, PHPCHUNKING */ public static function getBuildMode() { $package_mysqldump = DUP_Settings::Get('package_mysqldump'); $mysqlDumpPath = DUP_DB::getMySqlDumpPath(); return ($mysqlDumpPath && $package_mysqldump) ? self::BUILD_MODE_MYSQLDUMP : self::BUILD_MODE_PHP_SINGLE_THREAD; } /** * Returns the mysqldump path if the server is enabled to execute it otherwise false * * @return boolean|string */ public static function getMySqlDumpPath() { //Is shell_exec possible if (!DUP_Util::hasShellExec()) { return false; } $custom_mysqldump_path = DUP_Settings::Get('package_mysqldump_path'); $custom_mysqldump_path = (strlen($custom_mysqldump_path)) ? $custom_mysqldump_path : ''; $custom_mysqldump_path = escapeshellcmd($custom_mysqldump_path); // Common Windows Paths if (DUP_Util::isWindows()) { $paths = array( $custom_mysqldump_path, 'mysqldump.exe', self::getWindowsMySqlDumpRealPath(), 'C:/xampp/mysql/bin/mysqldump.exe', 'C:/Program Files/xampp/mysql/bin/mysqldump', 'C:/Program Files/MySQL/MySQL Server 6.0/bin/mysqldump', 'C:/Program Files/MySQL/MySQL Server 5.5/bin/mysqldump', 'C:/Program Files/MySQL/MySQL Server 5.4/bin/mysqldump' ); // Common Linux Paths } else { $paths = array( $custom_mysqldump_path, 'mysqldump', '/usr/local/bin/mysqldump', '/usr/local/mysql/bin/mysqldump', '/usr/mysql/bin/mysqldump', '/usr/bin/mysqldump', '/opt/local/lib/mysql6/bin/mysqldump', '/opt/local/lib/mysql5/bin/mysqldump', '/usr/bin/mysqldump', ); } $exec_available = function_exists('exec'); foreach ($paths as $path) { if (@file_exists($path)) { if (DUP_Util::isExecutable($path)) { return $path; } } elseif ($exec_available) { $out = array(); $rc = -1; $cmd = $path . ' --help'; @exec($cmd, $out, $rc); if ($rc === 0) { return $path; } } } return false; } /** * Get Sql query to create table which is given. * * @param string $table Table name * * @return string mysql query create table */ private static function getCreateTableQuery($table) { $row = $GLOBALS['wpdb']->get_row('SHOW CREATE TABLE `' . esc_sql($table) . '`', ARRAY_N); return $row[1]; } /** * Returns all collation types that are assigned to the tables in * the current database. Each element in the array is unique * * @param array $tables A list of tables to include from the search * * @return array Returns an array with all the character set being used */ public static function getTableCharSetList($tables) { $charSets = array(); try { foreach ($tables as $table) { $createTableQuery = self::getCreateTableQuery($table); if (preg_match('/ CHARSET=([^\s;]+)/i', $createTableQuery, $charsetMatch)) { if (!in_array($charsetMatch[1], $charSets)) { $charSets[] = $charsetMatch[1]; } } } return $charSets; } catch (Exception $ex) { return $charSets; } } /** * Returns all collation types that are assigned to the tables and columns table in * the current database. Each element in the array is unique * * @param string[] $tablesToInclude A list of tables to include in the search. * * @return string[] Returns an array with all the collation types being used */ public static function getTableCollationList($tablesToInclude) { global $wpdb; static $collations = null; if (is_null($collations)) { $collations = array(); //use half the number of tables since we are using them twice foreach (array_chunk($tablesToInclude, self::MAX_TABLE_COUNT_IN_PACKET) as $tablesChunk) { $sqlTables = implode(",", array_map(array(__CLASS__, 'escValueToQueryString'), $tablesChunk)); //UNION is by default DISTINCT $query = "SELECT `COLLATION_NAME` FROM `information_schema`.`columns` WHERE `COLLATION_NAME` IS NOT NULL AND `table_schema` = '{$wpdb->dbname}' " . "AND `table_name` in (" . $sqlTables . ")" . "UNION SELECT `TABLE_COLLATION` FROM `information_schema`.`tables` WHERE `TABLE_COLLATION` IS NOT NULL AND `table_schema` = '{$wpdb->dbname}' " . "AND `table_name` in (" . $sqlTables . ")"; if (!$wpdb->query($query)) { DUP_Log::Info("GET TABLE COLLATION ERROR: " . $wpdb->last_error); continue; } $collations = array_unique(array_merge($collations, $wpdb->get_col())); } $collations = array_values($collations); sort($collations); } return $collations; } /** * Returns list of MySQL engines used by $tablesToInclude in the current DB * * @param string[] $tablesToInclude tables to check the engines for * * @return string[] */ public static function getTableEngineList($tablesToInclude) { global $wpdb; static $engines = null; if (is_null($engines)) { $engines = array(); foreach (array_chunk($tablesToInclude, self::MAX_TABLE_COUNT_IN_PACKET) as $tablesChunk) { $query = "SELECT DISTINCT `ENGINE` FROM `information_schema`.`tables` WHERE `ENGINE` IS NOT NULL AND `table_schema` = '{$wpdb->dbname}' " . "AND `table_name` in (" . implode(",", array_map(array(__CLASS__, 'escValueToQueryString'), $tablesChunk)) . ")"; if (!$wpdb->query($query)) { DUP_Log::info("GET TABLE ENGINES ERROR: " . $wpdb->last_error); } $engines = array_merge($engines, $wpdb->get_col($query)); } $engines = array_values(array_unique($engines)); } return $engines; } /** * Returns an escaped SQL string * * @param string $sql The SQL to escape * @param bool $removePlaceholderEscape Patch for how the default WP function works. * * @return boolean|string * @also see: https://make.wordpress.org/core/2017/10/31/changed-behaviour-of-esc_sql-in-wordpress-4-8-3/ */ public static function escSQL($sql, $removePlaceholderEscape = false) { global $wpdb; $removePlaceholderEscape = $removePlaceholderEscape && self::$remove_placeholder_escape_exists; if ($removePlaceholderEscape) { return $wpdb->remove_placeholder_escape(@esc_sql($sql)); } else { return @esc_sql($sql); } } /** * This function escape sql string without add and remove remove_placeholder_escape * Don't use esc_sql wordpress function * * @param null|scalar $value input value * * @return string */ public static function escValueToQueryString($value) { if (is_null($value)) { return 'NULL'; } global $wpdb; return '"' . mysqli_real_escape_string($wpdb->dbh, (string) $value) . '"'; } }
BanaBridge News
https://validator.w3.org/feed/docs/rss2.html
Court Orders Ex-Weah Protocol Chief Jailed on US$8 Million Bail, Sends 15 Jurors to Prison Over Misconduct
Women Renew Call for War and Economic Crimes Court at Liberia’s Historic Peace Prayer Site
Finance Minister Ngafuan Urges Transparency, Accountability as Liberia Advances ARREST Agenda at UN Retreat
PPCC Donates ICT Equipment to 50 Government Institutions to Expand Electronic Procurement System
Liberia Commissions €100,000 Elemental Analyzer to Strengthen Environmental Research and Food Security
EPA Ends 16 Years of Renting with Purchase of Permanent Headquarters
West African Tax Bodies Deepen Partnership to Boost Revenue Mobilization, Launch Carbon Tax Study
Liberia Hosts Sierra Leone Procurement Delegation for E-GP Reform Study Tour
World Bank Praises Liberia’s Central Bank for Economic Stability and Private Sector Progress
Liberians See Slight Improvement in Corruption Fight, But Graft Still Viewed as Widespread, CENTAL Report Finds
Canada Afrique Care Foundation Set for Official Launch, Expanding Free Mental Health Access Across Canada and Africa
Weah Claims Liberia Has Become a “Narco State” as Opposition Rallies Behind Calls for Independent Probe into US$19 Million Cocaine Bust
EPA Boss Calls for Stronger Student Engagement, Unveils Push for Academic Partnership at UL Climate Symposium
Education Minister Urges Students to Embrace Tax Responsibility at National Student Tax Day
CDC Secretary General Urges U.S. Government to Review Support to Liberia National Police
Liberia Partners with CACFO to Expand Mental Health Services Ahead of Global Launch
Wreh-Toe Appointed Board Chair of CACFO as Foundation Strengthens Mental Health Push
GIABA Opens New Information Center Headquarters in Abidjan
Liberia Wins Fresh Backing as World Bank Group Executive Praises Progress, Pushes Faster Project Delivery
LRA Honors Liberia’s Top Taxpayers as Revenue Collections Hit Historic High
Root Cause in Question as Border Tensions Persist After Conakry Peace Deal
From Enforcement to Innovation: EPA Marks 2025 as a Defining Year for Liberia’s Environment
Weah Declares ‘Road to 2029 Begins Today’ as CDC Marks 22nd Anniversary in Zwedru
500 Documented Governance Failures: Activist Publishes Sweeping End-of-Year Indictment of Boakai Administration
CDC Calls for Probe into Border Crisis, Cites Alleged Mining Activities
Liberia Moves to Strengthen Small Businesses with $672,000 Packaging Solution Initiative
Former Public Works Minister Ruth Coker Collins Defends Zwedru Corridor Strategy, Calls for “Facts Over Rhetoric” in Infrastructure Debate
Power Shake-Up in CDC Diaspora: NEC Dissolves CDC-USA Interim Leadership, Appoints Rev. Muin to Lead U.S. Chapter
Tweah Reemerges, Sparks Fierce National Debate Over Governance and Liberia’s Future
Koijee Slams Tribal Politics and Political Manipulation in Lofa, Accuses Boakai Government
Mali and Burkina Faso Impose Reciprocal Travel Ban on U.S. Citizens
Guinea Election: A Turn Toward Continuity Amid Questions of Democratic Credibility
Liberia’s Revenue Grows Stronger as LRA Exceeds National Target for Second Year
Liberia’s Gender Legal Landscape: Laws in Place, Systems Lag Far Behind
Liberia’s Economy Gains Momentum as CBL Governor Highlights Progress at ECOWAS Meeting
Liberia Positions Itself for Eco Currency Entry as Economy Expands by 5.1%
From Overcrowded Classrooms to Renewal: NPA Mobilizes $1 Million to Transform UL
Ex-Public Works Minister Ruth Coker Collins Slams Ministry’s “Lack of Capacity,” Defends Her Infrastructure Record
CDC Expels Three Senior Members, Citing Alleged Alignment With Government and Undermining Party Ideology
UL to Celebrate 75 Years of Excellence
Saudi Fund Advances Liberia’s Push for Major Infrastructure Development
West African Financial Leaders Convene in Monrovia for ECOWAS Statutory Meetings
Unlocking Liberia’s Potential: Government Launches Major Revenue and Transparency Reforms
Incremental Gains, Enduring Impunity: Liberia’s CPI Improvement Fails the Test of Reform
Boakai’s Call for Unity Faces Scrutiny as Opposition, Citizens Question Actions Behind the Words
REMAPSEN Liberia Set to Strengthen Health and Environmental Reporting
Energy Sector Women Step Into the Spotlight at Liberia’s International Women’s Day Celebration
FeJAL Concludes Three-Day Retreat, Honors Outstanding Women Journalists
Dr. Rasha Kelej Named Among Africa’s 100 Most Influential Leaders
LAVA Honored for Strengthening Liberia–U.S. Ties at 2025 Military Ball