PluginProbe
The WP Remote WordPress Plugin / 6.76
The WP Remote WordPress Plugin v6.76
6.76 6.72 6.69 6.65 6.62 6.48 6.47 4.87 4.97 5.05 5.09 5.16 5.22 5.24 5.25 5.38 5.41 5.42 5.45 5.47 5.53 5.56 5.65 5.68 5.72 All 54 releases
← All changes | wp_db.php +40 -6 4.876.76 View file →
@@ -1,6 +1,6 @@
1 1 <?php
2 -
2 +// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
3 3 if (!defined('ABSPATH')) exit;
4 4 if (!class_exists('WPRWPDb')) :
5 5
6 6 class WPRWPDb {
@@ -39,8 +39,23 @@
39 39 global $wpdb;
40 40 return $wpdb->get_col($query, $col);
41 41 }
42 42
43 + public function getLastRowId($col_name, $table_name) {
44 + $query = "SELECT MAX($col_name) AS last_id FROM $table_name";
45 + $results = $this->getResult($query);
46 + if (empty($results) || !is_array($results) || !is_array($results[0]) ||
47 + !array_key_exists("last_id", $results[0])) {
48 + return null;
49 + }
50 + $last_id = $results[0]['last_id'];
51 + if ($last_id === null) {
52 + return 0;
53 + } else if (is_numeric($last_id) === true) {
54 + return (int) $last_id;
55 + }
56 + }
57 +
43 58 public function tableName($table) {
44 59 return $table[0];
45 60 }
46 61
@@ -48,8 +63,9 @@
48 63 $tables = $this->getResult("SHOW TABLES", ARRAY_N);
49 64 return array_map(array($this, 'tableName'), $tables);
50 65 }
51 66
67 +
52 68 public function showTableStatus() {
53 69 return $this->getResult("SHOW TABLE STATUS");
54 70 }
55 71
@@ -56,12 +72,25 @@
56 72 public function tableKeys($table) {
57 73 return $this->getResult("SHOW KEYS FROM $table;");
58 74 }
59 75
76 + public function showDbVariables($variable) {
77 + $variables = $this->getResult("Show variables like '%$variable%' ;");
78 + $result = array();
79 + foreach ($variables as $variable) {
80 + $result[$variable["Variable_name"]] = $variable["Value"];
81 + }
82 + return $result;
83 + }
84 +
60 85 public function describeTable($table) {
61 86 return $this->getResult("DESCRIBE $table;");
62 87 }
63 88
89 + public function showTableIndex($table) {
90 + return $this->getResult("SHOW INDEX FROM $table");
91 + }
92 +
64 93 public function checkTable($table, $type) {
65 94 return $this->getResult("CHECK TABLE $table $type;");
66 95 }
67 96
@@ -82,9 +111,9 @@
82 111 $table = $this->getBVTable($name);
83 112 if (!$this->isTablePresent($table)) {
84 113 if ($usedbdelta) {
85 114 if (!function_exists('dbDelta'))
86 - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
115 + require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
87 116 dbDelta($query);
88 117 } else {
89 118 $this->query($query);
90 119 }
@@ -151,9 +180,9 @@
151 180 } else {
152 181 return false;
153 182 }
154 183 }
155 -
184 +
156 185 public function deleteBVTableContent($name, $filter = "") {
157 186 $table = $this->getBVTable($name);
158 187 if ($this->isTablePresent($table)) {
159 188 return $this->query("DELETE FROM $table $filter;");
@@ -199,9 +228,15 @@
199 228 global $wpdb;
200 229 $table = $this->getBVTable($name);
201 230 return $wpdb->replace($table, $value);
202 231 }
203 -
232 +
233 + public function insertIntoBVTable($name, $value) {
234 + global $wpdb;
235 + $table = $this->getBVTable($name);
236 + return $wpdb->insert($table, $value);
237 + }
238 +
204 239 public function tinfo($name) {
205 240 $result = array();
206 241 $table = $this->getBVTable($name);
207 242
@@ -215,9 +250,8 @@
215 250 return $result;
216 251 }
217 252
218 253 public function getMysqlVersion() {
219 - global $wpdb;
220 - return $wpdb->db_version();
254 + return $this->showDbVariables('version')['version'];
221 255 }
222 256 }
223 257 endif;