/var/www/wordpress/wp-admin/includes/admin.php
/var/www/wordpress/wp-admin/includes/bookmark.php
/var/www/wordpress/wp-admin/includes/class-ftp-pure.php
/var/www/wordpress/wp-admin/includes/class-ftp-sockets.php
/var/www/wordpress/wp-admin/includes/class-ftp.php
/var/www/wordpress/wp-admin/includes/class-pclzip.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-base.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-direct.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-ftpext.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-ftpsockets.php
/var/www/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php
/var/www/wordpress/wp-admin/includes/class-wp-importer.php
/var/www/wordpress/wp-admin/includes/class-wp-upgrader.php
/var/www/wordpress/wp-admin/includes/comment.php
/var/www/wordpress/wp-admin/includes/continents-cities.php
/var/www/wordpress/wp-admin/includes/dashboard.php
/var/www/wordpress/wp-admin/includes/deprecated.php
/var/www/wordpress/wp-admin/includes/export.php
/var/www/wordpress/wp-admin/includes/file.php
/var/www/wordpress/wp-admin/includes/image-edit.php
/var/www/wordpress/wp-admin/includes/image.php
/var/www/wordpress/wp-admin/includes/import.php
/var/www/wordpress/wp-admin/includes/manifest.php
/var/www/wordpress/wp-admin/includes/media.php
/var/www/wordpress/wp-admin/includes/meta-boxes.php
/var/www/wordpress/wp-admin/includes/misc.php
/var/www/wordpress/wp-admin/includes/ms-deprecated.php
/var/www/wordpress/wp-admin/includes/ms.php
/var/www/wordpress/wp-admin/includes/nav-menu.php
/var/www/wordpress/wp-admin/includes/plugin-install.php
/var/www/wordpress/wp-admin/includes/plugin.php
/var/www/wordpress/wp-admin/includes/post.php
/var/www/wordpress/wp-admin/includes/schema.php
/var/www/wordpress/wp-admin/includes/taxonomy.php
/var/www/wordpress/wp-admin/includes/template.php
/var/www/wordpress/wp-admin/includes/theme-install.php
/var/www/wordpress/wp-admin/includes/theme.php
/var/www/wordpress/wp-admin/includes/update-core.php
/var/www/wordpress/wp-admin/includes/update.php
/var/www/wordpress/wp-admin/includes/upgrade.php
/var/www/wordpress/wp-admin/includes/user.php
/var/www/wordpress/wp-admin/includes/widgets.php
/var/www/wordpress/wp-admin/js/revisions-js.php
/var/www/wordpress/wp-admin/maint/repair.php
/var/www/wordpress/wp-admin/admin-ajax.php
/var/www/wordpress/wp-admin/admin-footer.php
/var/www/wordpress/wp-admin/admin-functions.php
/var/www/wordpress/wp-admin/admin-header.php
/var/www/wordpress/wp-admin/admin-post.php
/var/www/wordpress/wp-admin/admin.php
/var/www/wordpress/wp-admin/async-upload.php
/var/www/wordpress/wp-admin/comment.php
/var/www/wordpress/wp-admin/custom-background.php
/var/www/wordpress/wp-admin/custom-header.php
/var/www/wordpress/wp-admin/edit-attachment-rows.php
/var/www/wordpress/wp-admin/edit-comments.php
/var/www/wordpress/wp-admin/edit-form-advanced.php
/var/www/wordpress/wp-admin/edit-form-comment.php
/var/www/wordpress/wp-admin/edit-link-categories.php
/var/www/wordpress/wp-admin/edit-link-category-form.php
/var/www/wordpress/wp-admin/edit-link-form.php
/var/www/wordpress/wp-admin/edit-post-rows.php
/var/www/wordpress/wp-admin/edit-tag-form.php
/var/www/wordpress/wp-admin/edit-tags.php
/var/www/wordpress/wp-admin/edit.php
/var/www/wordpress/wp-admin/export.php
/var/www/wordpress/wp-admin/gears-manifest.php
/var/www/wordpress/wp-admin/import.php
/var/www/wordpress/wp-admin/index-extra.php
/var/www/wordpress/wp-admin/index.php
/var/www/wordpress/wp-admin/install-helper.php
/var/www/wordpress/wp-admin/install.php
/var/www/wordpress/wp-admin/link-add.php
/var/www/wordpress/wp-admin/link-category.php
/var/www/wordpress/wp-admin/link-manager.php
/var/www/wordpress/wp-admin/link-parse-opml.php
/var/www/wordpress/wp-admin/link.php
/var/www/wordpress/wp-admin/load-scripts.php
/var/www/wordpress/wp-admin/load-styles.php
/var/www/wordpress/wp-admin/media-new.php
/var/www/wordpress/wp-admin/media-upload.php
/var/www/wordpress/wp-admin/media.php
/var/www/wordpress/wp-admin/menu-header.php
/var/www/wordpress/wp-admin/menu.php
/var/www/wordpress/wp-admin/moderation.php
/var/www/wordpress/wp-admin/ms-admin.php
/var/www/wordpress/wp-admin/ms-delete-site.php
/var/www/wordpress/wp-admin/ms-edit.php
/var/www/wordpress/wp-admin/ms-options.php
/var/www/wordpress/wp-admin/ms-sites.php
/var/www/wordpress/wp-admin/ms-themes.php
/var/www/wordpress/wp-admin/ms-upgrade-network.php
/var/www/wordpress/wp-admin/ms-users.php
/var/www/wordpress/wp-admin/my-sites.php
/var/www/wordpress/wp-admin/nav-menus.php
/var/www/wordpress/wp-admin/network.php
/var/www/wordpress/wp-admin/options-discussion.php
/var/www/wordpress/wp-admin/options-general.php
/var/www/wordpress/wp-admin/options-head.php
/var/www/wordpress/wp-admin/options-media.php
/var/www/wordpress/wp-admin/options-permalink.php
/var/www/wordpress/wp-admin/options-privacy.php
/var/www/wordpress/wp-admin/options-reading.php
/var/www/wordpress/wp-admin/options-writing.php
/var/www/wordpress/wp-admin/options.php
/var/www/wordpress/wp-admin/plugin-editor.php
/var/www/wordpress/wp-admin/plugin-install.php
/var/www/wordpress/wp-admin/plugins.php
/var/www/wordpress/wp-admin/post-new.php
/var/www/wordpress/wp-admin/post.php
/var/www/wordpress/wp-admin/press-this.php
/var/www/wordpress/wp-admin/profile.php
/var/www/wordpress/wp-admin/revision.php
/var/www/wordpress/wp-admin/setup-config.php
/var/www/wordpress/wp-admin/sidebar.php
/var/www/wordpress/wp-admin/theme-editor.php
/var/www/wordpress/wp-admin/theme-install.php
/var/www/wordpress/wp-admin/themes.php
/var/www/wordpress/wp-admin/tools.php
/var/www/wordpress/wp-admin/update-core.php
/var/www/wordpress/wp-admin/update.php
/var/www/wordpress/wp-admin/upgrade-functions.php
/var/www/wordpress/wp-admin/upgrade.php
/var/www/wordpress/wp-admin/upload.php
/var/www/wordpress/wp-admin/user-edit.php
/var/www/wordpress/wp-admin/user-new.php
/var/www/wordpress/wp-admin/users.php
/var/www/wordpress/wp-admin/widgets.php
/var/www/wordpress/wp-content/languages/ru_RU.php
/var/www/wordpress/wp-content/plugins/akismet/akismet.php
/var/www/wordpress/wp-content/plugins/rh/rh.php
/var/www/wordpress/wp-content/plugins/hello.php
/var/www/wordpress/wp-content/plugins/index.php
/var/www/wordpress/wp-content/themes/twentyten/404.php
/var/www/wordpress/wp-content/themes/twentyten/archive.php
/var/www/wordpress/wp-content/themes/twentyten/attachment.php
/var/www/wordpress/wp-content/themes/twentyten/author.php
/var/www/wordpress/wp-content/themes/twentyten/category.php
/var/www/wordpress/wp-content/themes/twentyten/comments.php
/var/www/wordpress/wp-content/themes/twentyten/footer.php
/var/www/wordpress/wp-content/themes/twentyten/functions.php
/var/www/wordpress/wp-content/themes/twentyten/header.php
/var/www/wordpress/wp-content/themes/twentyten/index.php
/var/www/wordpress/wp-content/themes/twentyten/loop.php
/var/www/wordpress/wp-content/themes/twentyten/onecolumn-page.php
/var/www/wordpress/wp-content/themes/twentyten/page.php
/var/www/wordpress/wp-content/themes/twentyten/search.php
/var/www/wordpress/wp-content/themes/twentyten/sidebar-footer.php
/var/www/wordpress/wp-content/themes/twentyten/sidebar.php
/var/www/wordpress/wp-content/themes/twentyten/single.php
/var/www/wordpress/wp-content/themes/twentyten/tag.php
/var/www/wordpress/wp-content/themes/index.php
/var/www/wordpress/wp-content/index.php
/var/www/wordpress/wp-includes/js/tinymce/langs/wp-langs.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/Logger.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/EnchantSpell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/GoogleSpell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/PSpellShell.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/classes/SpellChecker.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/includes/general.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/config.php
/var/www/wordpress/wp-includes/js/tinymce/plugins/spellchecker/rpc.php
/var/www/wordpress/wp-includes/js/tinymce/wp-mce-help.php
/var/www/wordpress/wp-includes/js/tinymce/wp-tinymce.php
/var/www/wordpress/wp-includes/pomo/entry.php
/var/www/wordpress/wp-includes/pomo/mo.php
/var/www/wordpress/wp-includes/pomo/po.php
/var/www/wordpress/wp-includes/pomo/streams.php
/var/www/wordpress/wp-includes/pomo/translations.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/native.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/shell.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/string.php
/var/www/wordpress/wp-includes/Text/Diff/Engine/xdiff.php
/var/www/wordpress/wp-includes/Text/Diff/Renderer/inline.php
/var/www/wordpress/wp-includes/Text/Diff/Renderer.php
/var/www/wordpress/wp-includes/Text/Diff.php
/var/www/wordpress/wp-includes/theme-compat/comments-popup.php
/var/www/wordpress/wp-includes/theme-compat/comments.php
/var/www/wordpress/wp-includes/theme-compat/footer.php
/var/www/wordpress/wp-includes/theme-compat/header.php
/var/www/wordpress/wp-includes/theme-compat/sidebar.php
/var/www/wordpress/wp-includes/atomlib.php
/var/www/wordpress/wp-includes/author-template.php
/var/www/wordpress/wp-includes/bookmark-template.php
/var/www/wordpress/wp-includes/bookmark.php
/var/www/wordpress/wp-includes/cache.php
/var/www/wordpress/wp-includes/canonical.php
/var/www/wordpress/wp-includes/capabilities.php
/var/www/wordpress/wp-includes/category-template.php
/var/www/wordpress/wp-includes/category.php
/var/www/wordpress/wp-includes/class-feed.php
/var/www/wordpress/wp-includes/class-http.php
/var/www/wordpress/wp-includes/class-IXR.php
/var/www/wordpress/wp-includes/class-json.php
/var/www/wordpress/wp-includes/class-oembed.php
/var/www/wordpress/wp-includes/class-phpass.php
/var/www/wordpress/wp-includes/class-phpmailer.php
/var/www/wordpress/wp-includes/class-pop3.php
/var/www/wordpress/wp-includes/class-simplepie.php
/var/www/wordpress/wp-includes/class-smtp.php
/var/www/wordpress/wp-includes/class-snoopy.php
/var/www/wordpress/wp-includes/class.wp-dependencies.php
/var/www/wordpress/wp-includes/class.wp-scripts.php
/var/www/wordpress/wp-includes/class.wp-styles.php
/var/www/wordpress/wp-includes/classes.php
/var/www/wordpress/wp-includes/comment-template.php
/var/www/wordpress/wp-includes/comment.php
/var/www/wordpress/wp-includes/compat.php
/var/www/wordpress/wp-includes/cron.php
/var/www/wordpress/wp-includes/default-constants.php
/var/www/wordpress/wp-includes/default-embeds.php
/var/www/wordpress/wp-includes/default-filters.php
/var/www/wordpress/wp-includes/default-widgets.php
/var/www/wordpress/wp-includes/deprecated.php
/var/www/wordpress/wp-includes/feed-atom-comments.php
/var/www/wordpress/wp-includes/feed-atom.php
/var/www/wordpress/wp-includes/feed-rdf.php
/var/www/wordpress/wp-includes/feed-rss.php
/var/www/wordpress/wp-includes/feed-rss2-comments.php
/var/www/wordpress/wp-includes/feed-rss2.php
/var/www/wordpress/wp-includes/feed.php
/var/www/wordpress/wp-includes/formatting.php
/var/www/wordpress/wp-includes/functions.php
/var/www/wordpress/wp-includes/functions.wp-scripts.php
/var/www/wordpress/wp-includes/functions.wp-styles.php
/var/www/wordpress/wp-includes/general-template.php
/var/www/wordpress/wp-includes/http.php
/var/www/wordpress/wp-includes/kses.php
/var/www/wordpress/wp-includes/l10n.php
/var/www/wordpress/wp-includes/link-template.php
/var/www/wordpress/wp-includes/load.php
/var/www/wordpress/wp-includes/locale.php
/var/www/wordpress/wp-includes/media.php
/var/www/wordpress/wp-includes/meta.php
/var/www/wordpress/wp-includes/ms-blogs.php
/var/www/wordpress/wp-includes/ms-default-constants.php
/var/www/wordpress/wp-includes/ms-default-filters.php
/var/www/wordpress/wp-includes/ms-deprecated.php
/var/www/wordpress/wp-includes/ms-files.php
/var/www/wordpress/wp-includes/ms-functions.php
/var/www/wordpress/wp-includes/ms-load.php
/var/www/wordpress/wp-includes/ms-settings.php
/var/www/wordpress/wp-includes/nav-menu-template.php
/var/www/wordpress/wp-includes/nav-menu.php
/var/www/wordpress/wp-includes/pluggable-deprecated.php
/var/www/wordpress/wp-includes/pluggable.php
/var/www/wordpress/wp-includes/plugin.php
/var/www/wordpress/wp-includes/post-template.php
/var/www/wordpress/wp-includes/post-thumbnail-template.php
/var/www/wordpress/wp-includes/post.php
/var/www/wordpress/wp-includes/query.php
/var/www/wordpress/wp-includes/registration-functions.php
/var/www/wordpress/wp-includes/registration.php
/var/www/wordpress/wp-includes/rewrite.php
/var/www/wordpress/wp-includes/rss-functions.php
/var/www/wordpress/wp-includes/rss.php
/var/www/wordpress/wp-includes/script-loader.php
/var/www/wordpress/wp-includes/shortcodes.php
/var/www/wordpress/wp-includes/taxonomy.php
/var/www/wordpress/wp-includes/template-loader.php
/var/www/wordpress/wp-includes/theme.php
/var/www/wordpress/wp-includes/update.php
/var/www/wordpress/wp-includes/user.php
/var/www/wordpress/wp-includes/vars.php
/var/www/wordpress/wp-includes/version.php
/var/www/wordpress/wp-includes/widgets.php
/var/www/wordpress/wp-includes/wp-db.php
#CodeDescriptions
1<?php
2/**
3 * WordPress DB Class
4 *
5 * Original code from {@link http://php.justinvincent.com Justin Vincent (justin@visunet.ie)}
6 *
7 * @package WordPress
8 * @subpackage Database
9 * @since 0.71
10 */
11
12/**
13 * @since 0.71
14 */
15define( 'EZSQL_VERSION', 'WP1.25' );
16
17/**
18 * @since 0.71
19 */
20define( 'OBJECT', 'OBJECT', true );
21
22/**
23 * @since 2.5.0
24 */
25define( 'OBJECT_K', 'OBJECT_K' );
26
27/**
28 * @since 0.71
29 */
30define( 'ARRAY_A', 'ARRAY_A' );
31
32/**
33 * @since 0.71
34 */
35define( 'ARRAY_N', 'ARRAY_N' );
36
37/**
38 * WordPress Database Access Abstraction Object
39 *
40 * It is possible to replace this class with your own
41 * by setting the $wpdb global variable in wp-content/db.php
42 * file with your class. You can name it wpdb also, since
43 * this file will not be included, if the other file is
44 * available.
45 *
46 * @link http://codex.wordpress.org/Function_Reference/wpdb_Class
47 *
48 * @package WordPress
49 * @subpackage Database
50 * @since 0.71
51 * @final
52 */
53class wpdb {
54
55 /**
56 * Whether to show SQL/DB errors
57 *
58 * @since 0.71
59 * @access private
60 * @var bool
61 */
62 var $show_errors = false;
63
64 /**
65 * Whether to suppress errors during the DB bootstrapping.
66 *
67 * @access private
68 * @since 2.5
69 * @var bool
70 */
71 var $suppress_errors = false;
72
73 /**
74 * The last error during query.
75 *
76 * @see get_last_error()
77 * @since 2.5
78 * @access private
79 * @var string
80 */
81 var $last_error = '';
82
83 /**
84 * Amount of queries made
85 *
86 * @since 1.2.0
87 * @access private
88 * @var int
89 */
90 var $num_queries = 0;
91
92 /**
93 * Count of rows returned by previous query
94 *
95 * @since 1.2
96 * @access private
97 * @var int
98 */
99 var $num_rows = 0;
100
101 /**
102 * Count of affected rows by previous query
103 *
104 * @since 0.71
105 * @access private
106 * @var int
107 */
108 var $rows_affected = 0;
109
110 /**
111 * The ID generated for an AUTO_INCREMENT column by the previous query (usually INSERT).
112 *
113 * @since 0.71
114 * @access public
115 * @var int
116 */
117 var $insert_id = 0;
118
119 /**
120 * Saved result of the last query made
121 *
122 * @since 1.2.0
123 * @access private
124 * @var array
125 */
126 var $last_query;
127
128 /**
129 * Results of the last query made
130 *
131 * @since 1.0.0
132 * @access private
133 * @var array|null
134 */
135 var $last_result;
136
137 /**
138 * Saved info on the table column
139 *
140 * @since 1.2.0
141 * @access private
142 * @var array
143 */
144 var $col_info;
145
146 /**
147 * Saved queries that were executed
148 *
149 * @since 1.5.0
150 * @access private
151 * @var array
152 */
153 var $queries;
154
155 /**
156 * WordPress table prefix
157 *
158 * You can set this to have multiple WordPress installations
159 * in a single database. The second reason is for possible
160 * security precautions.
161 *
162 * @since 0.71
163 * @access private
164 * @var string
165 */
166 var $prefix = '';
167
168 /**
169 * Whether the database queries are ready to start executing.
170 *
171 * @since 2.5.0
172 * @access private
173 * @var bool
174 */
175 var $ready = false;
176
177 /**
178 * {@internal Missing Description}}
179 *
180 * @since 3.0.0
181 * @access public
182 * @var int
183 */
184 var $blogid = 0;
185
186 /**
187 * {@internal Missing Description}}
188 *
189 * @since 3.0.0
190 * @access public
191 * @var int
192 */
193 var $siteid = 0;
194
195 /**
196 * List of WordPress per-blog tables
197 *
198 * @since 2.5.0
199 * @access private
200 * @see wpdb::tables()
201 * @var array
202 */
203 var $tables = array( 'posts', 'comments', 'links', 'options', 'postmeta',
204 'terms', 'term_taxonomy', 'term_relationships', 'commentmeta' );
205
206 /**
207 * List of deprecated WordPress tables
208 *
209 * categories, post2cat, and link2cat were deprecated in 2.3.0, db version 5539
210 *
211 * @since 2.9.0
212 * @access private
213 * @see wpdb::tables()
214 * @var array
215 */
216 var $old_tables = array( 'categories', 'post2cat', 'link2cat' );
217
218 /**
219 * List of WordPress global tables
220 *
221 * @since 3.0.0
222 * @access private
223 * @see wpdb::tables()
224 * @var array
225 */
226 var $global_tables = array( 'users', 'usermeta' );
227
228 /**
229 * List of Multisite global tables
230 *
231 * @since 3.0.0
232 * @access private
233 * @see wpdb::tables()
234 * @var array
235 */
236 var $ms_global_tables = array( 'blogs', 'signups', 'site', 'sitemeta',
237 'sitecategories', 'registration_log', 'blog_versions' );
238
239 /**
240 * WordPress Comments table
241 *
242 * @since 1.5.0
243 * @access public
244 * @var string
245 */
246 var $comments;
247
248 /**
249 * WordPress Comment Metadata table
250 *
251 * @since 2.9.0
252 * @access public
253 * @var string
254 */
255 var $commentmeta;
256
257 /**
258 * WordPress Links table
259 *
260 * @since 1.5.0
261 * @access public
262 * @var string
263 */
264 var $links;
265
266 /**
267 * WordPress Options table
268 *
269 * @since 1.5.0
270 * @access public
271 * @var string
272 */
273 var $options;
274
275 /**
276 * WordPress Post Metadata table
277 *
278 * @since 1.5.0
279 * @access public
280 * @var string
281 */
282 var $postmeta;
283
284 /**
285 * WordPress Posts table
286 *
287 * @since 1.5.0
288 * @access public
289 * @var string
290 */
291 var $posts;
292
293 /**
294 * WordPress Terms table
295 *
296 * @since 2.3.0
297 * @access public
298 * @var string
299 */
300 var $terms;
301
302 /**
303 * WordPress Term Relationships table
304 *
305 * @since 2.3.0
306 * @access public
307 * @var string
308 */
309 var $term_relationships;
310
311 /**
312 * WordPress Term Taxonomy table
313 *
314 * @since 2.3.0
315 * @access public
316 * @var string
317 */
318 var $term_taxonomy;
319
320 /*
321 * Global and Multisite tables
322 */
323
324 /**
325 * WordPress User Metadata table
326 *
327 * @since 2.3.0
328 * @access public
329 * @var string
330 */
331 var $usermeta;
332
333 /**
334 * WordPress Users table
335 *
336 * @since 1.5.0
337 * @access public
338 * @var string
339 */
340 var $users;
341
342 /**
343 * Multisite Blogs table
344 *
345 * @since 3.0.0
346 * @access public
347 * @var string
348 */
349 var $blogs;
350
351 /**
352 * Multisite Blog Versions table
353 *
354 * @since 3.0.0
355 * @access public
356 * @var string
357 */
358 var $blog_versions;
359
360 /**
361 * Multisite Registration Log table
362 *
363 * @since 3.0.0
364 * @access public
365 * @var string
366 */
367 var $registration_log;
368
369 /**
370 * Multisite Signups table
371 *
372 * @since 3.0.0
373 * @access public
374 * @var string
375 */
376 var $signups;
377
378 /**
379 * Multisite Sites table
380 *
381 * @since 3.0.0
382 * @access public
383 * @var string
384 */
385 var $site;
386
387 /**
388 * Multisite Sitewide Terms table
389 *
390 * @since 3.0.0
391 * @access public
392 * @var string
393 */
394 var $sitecategories;
395
396 /**
397 * Multisite Site Metadata table
398 *
399 * @since 3.0.0
400 * @access public
401 * @var string
402 */
403 var $sitemeta;
404
405 /**
406 * Format specifiers for DB columns. Columns not listed here default to %s. Initialized during WP load.
407 *
408 * Keys are column names, values are format types: 'ID' => '%d'
409 *
410 * @since 2.8.0
411 * @see wpdb:prepare()
412 * @see wpdb:insert()
413 * @see wpdb:update()
414 * @see wp_set_wpdb_vars()
415 * @access public
416 * @var array
417 */
418 var $field_types = array();
419
420 /**
421 * Database table columns charset
422 *
423 * @since 2.2.0
424 * @access public
425 * @var string
426 */
427 var $charset;
428
429 /**
430 * Database table columns collate
431 *
432 * @since 2.2.0
433 * @access public
434 * @var string
435 */
436 var $collate;
437
438 /**
439 * Whether to use mysql_real_escape_string
440 *
441 * @since 2.8.0
442 * @access public
443 * @var bool
444 */
445 var $real_escape = false;
446
447 /**
448 * Database Username
449 *
450 * @since 2.9.0
451 * @access private
452 * @var string
453 */
454 var $dbuser;
455
456 /**
457 * A textual description of the last query/get_row/get_var call
458 *
459 * @since unknown
460 * @access public
461 * @var string
462 */
463 var $func_call;
464
465 /**
466 * Connects to the database server and selects a database
467 *
468 * PHP4 compatibility layer for calling the PHP5 constructor.
469 *
470 * @uses wpdb::__construct() Passes parameters and returns result
471 * @since 0.71
472 *
473 * @param string $dbuser MySQL database user
474 * @param string $dbpassword MySQL database password
475 * @param string $dbname MySQL database name
476 * @param string $dbhost MySQL database host
477 */
478 function wpdb( $dbuser, $dbpassword, $dbname, $dbhost ) {
479 if( defined( 'WP_USE_MULTIPLE_DB' ) && WP_USE_MULTIPLE_DB )
480 $this->db_connect();
481 return $this->__construct( $dbuser, $dbpassword, $dbname, $dbhost );
482 }
483
484 /**
485 * Connects to the database server and selects a database
486 *
487 * PHP5 style constructor for compatibility with PHP5. Does
488 * the actual setting up of the class properties and connection
489 * to the database.
490 *
491 * @link http://core.trac.wordpress.org/ticket/3354
492 * @since 2.0.8
493 *
494 * @param string $dbuser MySQL database user
495 * @param string $dbpassword MySQL database password
496 * @param string $dbname MySQL database name
497 * @param string $dbhost MySQL database host
498 */
499 function __construct( $dbuser, $dbpassword, $dbname, $dbhost ) {
500 register_shutdown_function( array( &$this, '__destruct' ) );
501
502 if ( WP_DEBUG )
503 $this->show_errors();
504
505 if ( is_multisite() ) {
506 $this->charset = 'utf8';
507 if ( defined( 'DB_COLLATE' ) && DB_COLLATE )
508 $this->collate = DB_COLLATE;
509 else
510 $this->collate = 'utf8_general_ci';
511 } elseif ( defined( 'DB_COLLATE' ) ) {
512 $this->collate = DB_COLLATE;
513 }
514
515 if ( defined( 'DB_CHARSET' ) )
516 $this->charset = DB_CHARSET;
517
518 $this->dbuser = $dbuser;
519
520 $this->dbh = @mysql_connect( $dbhost, $dbuser, $dbpassword, true );
521 if ( !$this->dbh ) {
522 $this->bail( sprintf( /*WP_I18N_DB_CONN_ERROR*/"
523<h1>Error establishing a database connection</h1>
524<p>This either means that the username and password information in your <code>wp-config.php</code> file is incorrect or we can't contact the database server at <code>%s</code>. This could mean your host's database server is down.</p>
525<ul>
526 <li>Are you sure you have the correct username and password?</li>
527 <li>Are you sure that you have typed the correct hostname?</li>
528 <li>Are you sure that the database server is running?</li>
529</ul>
530<p>If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href='http://wordpress.org/support/'>WordPress Support Forums</a>.</p>
531"/*/WP_I18N_DB_CONN_ERROR*/, $dbhost ), 'db_connect_fail' );
532 return;
533 }
534
535 $this->ready = true;
536
537 if ( $this->has_cap( 'collation' ) && !empty( $this->charset ) ) {
538 if ( function_exists( 'mysql_set_charset' ) ) {
539 mysql_set_charset( $this->charset, $this->dbh );
540 $this->real_escape = true;
541 } else {
542 $query = $this->prepare( 'SET NAMES %s', $this->charset );
543 if ( ! empty( $this->collate ) )
544 $query .= $this->prepare( ' COLLATE %s', $this->collate );
545 $this->query( $query );
546 }
547 }
548
549 $this->select( $dbname, $this->dbh );
550 }
551
552 /**
553 * PHP5 style destructor and will run when database object is destroyed.
554 *
555 * @see wpdb::__construct()
556 * @since 2.0.8
557 * @return bool true
558 */
559 function __destruct() {
560 return true;
561 }
562
563 /**
564 * Sets the table prefix for the WordPress tables.
565 *
566 * @since 2.5.0
567 *
568 * @param string $prefix Alphanumeric name for the new prefix.
569 * @return string|WP_Error Old prefix or WP_Error on error
570 */
571 function set_prefix( $prefix, $set_table_names = true ) {
572
573 if ( preg_match( '|[^a-z0-9_]|i', $prefix ) )
574 return new WP_Error('invalid_db_prefix', /*WP_I18N_DB_BAD_PREFIX*/'Invalid database prefix'/*/WP_I18N_DB_BAD_PREFIX*/);
575
576 $old_prefix = is_multisite() ? '' : $prefix;
577
578 if ( isset( $this->base_prefix ) )
579 $old_prefix = $this->base_prefix;
580
581 $this->base_prefix = $prefix;
582
583 if ( $set_table_names ) {
584 foreach ( $this->tables( 'global' ) as $table => $prefixed_table )
585 $this->$table = $prefixed_table;
586
587 if ( is_multisite() && empty( $this->blogid ) )
588 return $old_prefix;
589
590 $this->prefix = $this->get_blog_prefix();
591
592 foreach ( $this->tables( 'blog' ) as $table => $prefixed_table )
593 $this->$table = $prefixed_table;
594
595 foreach ( $this->tables( 'old' ) as $table => $prefixed_table )
596 $this->$table = $prefixed_table;
597 }
598 return $old_prefix;
599 }
600
601 /**
602 * Sets blog id.
603 *
604 * @since 3.0.0
605 * @access public
606 * @param int $blog_id
607 * @param int $site_id Optional.
608 * @return string previous blog id
609 */
610 function set_blog_id( $blog_id, $site_id = 0 ) {
611 if ( ! empty( $site_id ) )
612 $this->siteid = $site_id;
613
614 $old_blog_id = $this->blogid;
615 $this->blogid = $blog_id;
616
617 $this->prefix = $this->get_blog_prefix();
618
619 foreach ( $this->tables( 'blog' ) as $table => $prefixed_table )
620 $this->$table = $prefixed_table;
621
622 foreach ( $this->tables( 'old' ) as $table => $prefixed_table )
623 $this->$table = $prefixed_table;
624
625 return $old_blog_id;
626 }
627
628 /**
629 * Gets blog prefix.
630 *
631 * @uses is_multisite()
632 * @since 3.0.0
633 * @param int $blog_id Optional.
634 * @return string Blog prefix.
635 */
636 function get_blog_prefix( $blog_id = null ) {
637 if ( is_multisite() ) {
638 if ( null === $blog_id )
639 $blog_id = $this->blogid;
640 if ( defined( 'MULTISITE' ) && ( 0 == $blog_id || 1 == $blog_id ) )
641 return $this->base_prefix;
642 else
643 return $this->base_prefix . $blog_id . '_';
644 } else {
645 return $this->base_prefix;
646 }
647 }
648
649 /**
650 * Returns an array of WordPress tables.
651 *
652 * Also allows for the CUSTOM_USER_TABLE and CUSTOM_USER_META_TABLE to
653 * override the WordPress users and usersmeta tables that would otherwise
654 * be determined by the prefix.
655 *
656 * The scope argument can take one of the following:
657 *
658 * 'all' - returns 'all' and 'global' tables. No old tables are returned.
659 * 'blog' - returns the blog-level tables for the queried blog.
660 * 'global' - returns the global tables for the installation, returning multisite tables only if running multisite.
661 * 'ms_global' - returns the multisite global tables, regardless if current installation is multisite.
662 * 'old' - returns tables which are deprecated.
663 *
664 * @since 3.0.0
665 * @uses wpdb::$tables
666 * @uses wpdb::$old_tables
667 * @uses wpdb::$global_tables
668 * @uses wpdb::$ms_global_tables
669 * @uses is_multisite()
670 *
671 * @param string $scope Optional. Can be all, global, ms_global, blog, or old tables. Defaults to all.
672 * @param bool $prefix Optional. Whether to include table prefixes. Default true. If blog
673 * prefix is requested, then the custom users and usermeta tables will be mapped.
674 * @param int $blog_id Optional. The blog_id to prefix. Defaults to wpdb::$blogid. Used only when prefix is requested.
675 * @return array Table names. When a prefix is requested, the key is the unprefixed table name.
676 */
677 function tables( $scope = 'all', $prefix = true, $blog_id = 0 ) {
678 switch ( $scope ) {
679 case 'all' :
680 $tables = array_merge( $this->global_tables, $this->tables );
681 if ( is_multisite() )
682 $tables = array_merge( $tables, $this->ms_global_tables );
683 break;
684 case 'blog' :
685 $tables = $this->tables;
686 break;
687 case 'global' :
688 $tables = $this->global_tables;
689 if ( is_multisite() )
690 $tables = array_merge( $tables, $this->ms_global_tables );
691 break;
692 case 'ms_global' :
693 $tables = $this->ms_global_tables;
694 break;
695 case 'old' :
696 $tables = $this->old_tables;
697 break;
698 default :
699 return array();
700 break;
701 }
702
703 if ( $prefix ) {
704 if ( ! $blog_id )
705 $blog_id = $this->blogid;
706 $blog_prefix = $this->get_blog_prefix( $blog_id );
707 $base_prefix = $this->base_prefix;
708 $global_tables = array_merge( $this->global_tables, $this->ms_global_tables );
709 foreach ( $tables as $k => $table ) {
710 if ( in_array( $table, $global_tables ) )
711 $tables[ $table ] = $base_prefix . $table;
712 else
713 $tables[ $table ] = $blog_prefix . $table;
714 unset( $tables[ $k ] );
715 }
716
717 if ( isset( $tables['users'] ) && defined( 'CUSTOM_USER_TABLE' ) )
718 $tables['users'] = CUSTOM_USER_TABLE;
719
720 if ( isset( $tables['usermeta'] ) && defined( 'CUSTOM_USER_META_TABLE' ) )
721 $tables['usermeta'] = CUSTOM_USER_META_TABLE;
722 }
723
724 return $tables;
725 }
726
727 /**
728 * Selects a database using the current database connection.
729 *
730 * The database name will be changed based on the current database
731 * connection. On failure, the execution will bail and display an DB error.
732 *
733 * @since 0.71
734 *
735 * @param string $db MySQL database name
736 * @param resource $dbh Optional link identifier.
737 * @return null Always null.
738 */
739 function select( $db, $dbh = null) {
740 if ( is_null($dbh) )
741 $dbh = $this->dbh;
742
743 if ( !@mysql_select_db( $db, $dbh ) ) {
744 $this->ready = false;
745 $this->bail( sprintf( /*WP_I18N_DB_SELECT_DB*/'
746<h1>Can’t select database</h1>
747<p>We were able to connect to the database server (which means your username and password is okay) but not able to select the <code>%1$s</code> database.</p>
748<ul>
749<li>Are you sure it exists?</li>
750<li>Does the user <code>%2$s</code> have permission to use the <code>%1$s</code> database?</li>
751<li>On some systems the name of your database is prefixed with your username, so it would be like <code>username_%1$s</code>. Could that be the problem?</li>
752</ul>
753<p>If you don\'t know how to set up a database you should <strong>contact your host</strong>. If all else fails you may find help at the <a href="http://wordpress.org/support/">WordPress Support Forums</a>.</p>'/*/WP_I18N_DB_SELECT_DB*/, $db, $this->dbuser ), 'db_select_fail' );
754 return;
755 }
756 }
757
758 /**
759 * Weak escape, using addslashes()
760 *
761 * @see addslashes()
762 * @since 2.8.0
763 * @access private
764 *
765 * @param string $string
766 * @return string
767 */
768 function _weak_escape( $string ) {
769 return addslashes( $string );
770 }
771
772 /**
773 * Real escape, using mysql_real_escape_string() or addslashes()
774 *
775 * @see mysql_real_escape_string()
776 * @see addslashes()
777 * @since 2.8
778 * @access private
779 *
780 * @param string $string to escape
781 * @return string escaped
782 */
783 function _real_escape( $string ) {
784 if ( $this->dbh && $this->real_escape )
785 return mysql_real_escape_string( $string, $this->dbh );
786 else
787 return addslashes( $string );
788 }
789
790 /**
791 * Escape data. Works on arrays.
792 *
793 * @uses wpdb::_escape()
794 * @uses wpdb::_real_escape()
795 * @since 2.8
796 * @access private
797 *
798 * @param string|array $data
799 * @return string|array escaped
800 */
801 function _escape( $data ) {
802 if ( is_array( $data ) ) {
803 foreach ( (array) $data as $k => $v ) {
804 if ( is_array($v) )
805 $data[$k] = $this->_escape( $v );
806 else
807 $data[$k] = $this->_real_escape( $v );
808 }
809 } else {
810 $data = $this->_real_escape( $data );
811 }
812
813 return $data;
814 }
815
816 /**
817 * Escapes content for insertion into the database using addslashes(), for security.
818 *
819 * Works on arrays.
820 *
821 * @since 0.71
822 * @param string|array $data to escape
823 * @return string|array escaped as query safe string
824 */
825 function escape( $data ) {
826 if ( is_array( $data ) ) {
827 foreach ( (array) $data as $k => $v ) {
828 if ( is_array( $v ) )
829 $data[$k] = $this->escape( $v );
830 else
831 $data[$k] = $this->_weak_escape( $v );
832 }
833 } else {
834 $data = $this->_weak_escape( $data );
835 }
836
837 return $data;
838 }
839
840 /**
841 * Escapes content by reference for insertion into the database, for security
842 *
843 * @uses wpdb::_real_escape()
844 * @since 2.3.0
845 * @param string $string to escape
846 * @return void
847 */
848 function escape_by_ref( &$string ) {
849 $string = $this->_real_escape( $string );
850 }
851
852 /**
853 * Prepares a SQL query for safe execution. Uses sprintf()-like syntax.
854 *
855 * The following directives can be used in the query format string:
856 * %d (decimal number)
857 * %s (string)
858 * %% (literal percentage sign - no argument needed)
859 *
860 * Both %d and %s are to be left unquoted in the query string and they need an argument passed for them.
861 * Literals (%) as parts of the query must be properly written as %%.
862 *
863 * This function only supports a small subset of the sprintf syntax; it only supports %d (decimal number), %s (string).
864 * Does not support sign, padding, alignment, width or precision specifiers.
865 * Does not support argument numbering/swapping.
866 *
867 * May be called like {@link http://php.net/sprintf sprintf()} or like {@link http://php.net/vsprintf vsprintf()}.
868 *
869 * Both %d and %s should be left unquoted in the query string.
870 *
871 * <code>
872 * wpdb::prepare( "SELECT * FROM `table` WHERE `column` = %s AND `field` = %d", 'foo', 1337 )
873 * wpdb::prepare( "SELECT DATE_FORMAT(`field`, '%%c') FROM `table` WHERE `column` = %s", 'foo' );
874 * </code>
875 *
876 * @link http://php.net/sprintf Description of syntax.
877 * @since 2.3.0
878 *
879 * @param string $query Query statement with sprintf()-like placeholders
880 * @param array|mixed $args The array of variables to substitute into the query's placeholders if being called like
881 * {@link http://php.net/vsprintf vsprintf()}, or the first variable to substitute into the query's placeholders if
882 * being called like {@link http://php.net/sprintf sprintf()}.
883 * @param mixed $args,... further variables to substitute into the query's placeholders if being called like
884 * {@link http://php.net/sprintf sprintf()}.
885 * @return null|false|string Sanitized query string, null if there is no query, false if there is an error and string
886 * if there was something to prepare
887 */
888 function prepare( $query = null ) { // ( $query, *$args )
889 if ( is_null( $query ) )
890 return;
891
892 $args = func_get_args();
893 array_shift( $args );
894 // If args were passed as an array (as in vsprintf), move them up
895 if ( isset( $args[0] ) && is_array($args[0]) )
896 $args = $args[0];
897 $query = str_replace( "'%s'", '%s', $query ); // in case someone mistakenly already singlequoted it
898 $query = str_replace( '"%s"', '%s', $query ); // doublequote unquoting
899 $query = preg_replace( '|(?<!%)%s|', "'%s'", $query ); // quote the strings, avoiding escaped strings like %%s
900 array_walk( $args, array( &$this, 'escape_by_ref' ) );
901 return @vsprintf( $query, $args );//Cross Site Scripting
902 }
903
904 /**
905 * Print SQL/DB error.
906 *
907 * @since 0.71
908 * @global array $EZSQL_ERROR Stores error information of query and error string
909 *
910 * @param string $str The error to display
911 * @return bool False if the showing of errors is disabled.
912 */
913 function print_error( $str = '' ) {
914 global $EZSQL_ERROR;
915
916 if ( !$str )
917 $str = mysql_error( $this->dbh );
918 $EZSQL_ERROR[] = array( 'query' => $this->last_query, 'error_str' => $str );
919
920 if ( $this->suppress_errors )
921 return false;
922
923 if ( $caller = $this->get_caller() )
924 $error_str = sprintf( /*WP_I18N_DB_QUERY_ERROR_FULL*/'WordPress database error %1$s for query %2$s made by %3$s'/*/WP_I18N_DB_QUERY_ERROR_FULL*/, $str, $this->last_query, $caller );
925 else
926 $error_str = sprintf( /*WP_I18N_DB_QUERY_ERROR*/'WordPress database error %1$s for query %2$s'/*/WP_I18N_DB_QUERY_ERROR*/, $str, $this->last_query );
927
928 if ( function_exists( 'error_log' )
929 && ( $log_file = @ini_get( 'error_log' ) )
930 && ( 'syslog' == $log_file || @is_writable( $log_file ) )
931 )
932 @error_log( $error_str );//Connection Handling
933
934 // Are we showing errors?
935 if ( ! $this->show_errors )
936 return false;
937
938 // If there is an error then take note of it
939 if ( is_multisite() ) {
940 $msg = "WordPress database error: [$str]\n{$this->last_query}\n";
941 if ( defined( 'ERRORLOGFILE' ) )
942 error_log( $msg, 3, ERRORLOGFILE );//Connection Handling
943 if ( defined( 'DIEONDBERROR' ) )
944 wp_die( $msg );
945 } else {
946 $str = htmlspecialchars( $str, ENT_QUOTES );
947 $query = htmlspecialchars( $this->last_query, ENT_QUOTES );
948
949 print "<div id='error'>
950 <p class='wpdberror'><strong>WordPress database error:</strong> [$str]<br />
951 <code>$query</code></p>
952 </div>";
953 }
954 }
955
956 /**
957 * Enables showing of database errors.
958 *
959 * This function should be used only to enable showing of errors.
960 * wpdb::hide_errors() should be used instead for hiding of errors. However,
961 * this function can be used to enable and disable showing of database
962 * errors.
963 *
964 * @since 0.71
965 * @see wpdb::hide_errors()
966 *
967 * @param bool $show Whether to show or hide errors
968 * @return bool Old value for showing errors.
969 */
970 function show_errors( $show = true ) {
971 $errors = $this->show_errors;
972 $this->show_errors = $show;
973 return $errors;
974 }
975
976 /**
977 * Disables showing of database errors.
978 *
979 * By default database errors are not shown.
980 *
981 * @since 0.71
982 * @see wpdb::show_errors()
983 *
984 * @return bool Whether showing of errors was active
985 */
986 function hide_errors() {
987 $show = $this->show_errors;
988 $this->show_errors = false;
989 return $show;
990 }
991
992 /**
993 * Whether to suppress database errors.
994 *
995 * By default database errors are suppressed, with a simple
996 * call to this function they can be enabled.
997 *
998 * @since 2.5
999 * @see wpdb::hide_errors()
1000 * @param bool $suppress Optional. New value. Defaults to true.
/var/www/wordpress/wp-includes/wp-diff.php
/var/www/wordpress/index.php
/var/www/wordpress/wp-activate.php
/var/www/wordpress/wp-app.php
/var/www/wordpress/wp-atom.php
/var/www/wordpress/wp-blog-header.php
/var/www/wordpress/wp-comments-post.php
/var/www/wordpress/wp-commentsrss2.php
/var/www/wordpress/wp-config-sample.php
/var/www/wordpress/wp-cron.php
/var/www/wordpress/wp-feed.php
/var/www/wordpress/wp-links-opml.php
/var/www/wordpress/wp-load.php
/var/www/wordpress/wp-login.php
/var/www/wordpress/wp-mail.php
/var/www/wordpress/wp-pass.php
/var/www/wordpress/wp-rdf.php
/var/www/wordpress/wp-register.php
/var/www/wordpress/wp-rss.php
/var/www/wordpress/wp-rss2.php
/var/www/wordpress/wp-settings.php
/var/www/wordpress/wp-signup.php
/var/www/wordpress/wp-trackback.php
/var/www/wordpress/xmlrpc.php