W3 Total Cache - Version 0.9.2.4

Version Description

  • Added support for Microsoft SQL Server
  • Added API support for MediaTemple ProCDN (EdgeCast)
  • Added set_time_limit to self test
  • Fixed LiteSpeed web server support
  • Fixed native hostname 301 redirect
  • Fixed redundant object origin push export
  • Fixed WSOD (white screen of death) caused by minify in some hosting configurations
  • Fixed text encoding in feeds
  • Fixed incorrect mime-type in feeds (which caused feedburner anomalies)
  • Fixed array to string notices
  • Fixed expires header support for AWS
  • Fixed minification of font-family
  • Fixed object cache write issue in WP Admin
  • Improved (reduced) memory utilization by up to 70%
  • Improved disk enhanced page caching performance
  • Improved object caching performance
  • Improved activation reliability
  • Improved reliability of minify auto mode
  • Improved security (added nonces, no directory indexing, prevent direct file access)
  • Improved compatibility with network based file systems
Download this release

Release Info

Developer fredericktownes
Plugin Icon 128x128 W3 Total Cache
Version 0.9.2.4
Comparing to
See all releases

Code changes from version 0.9.2.3 to 0.9.2.4

Files changed (115) hide show
  1. db/mssql.php +0 -1255
  2. inc/.htaccess +3 -0
  3. inc/define.php +93 -974
  4. inc/email/index.html +0 -0
  5. inc/email/minify_error_notification.php +7 -0
  6. inc/email/{support_request.phtml → support_request.php} +1 -0
  7. inc/{error.phtml → error.php} +2 -1
  8. inc/functions/activation.php +78 -0
  9. inc/{compat.php → functions/compat.php} +19 -0
  10. inc/functions/extract.php +60 -0
  11. inc/functions/file.php +177 -0
  12. inc/functions/http.php +81 -0
  13. inc/functions/mime.php +74 -0
  14. inc/{plugin.php → functions/plugin.php} +9 -29
  15. inc/functions/rule.php +239 -0
  16. inc/functions/url.php +103 -0
  17. inc/index.html +0 -0
  18. inc/js/widget.js +0 -11
  19. inc/lightbox/{cdn_s3_bucket_location.phtml → cdn_s3_bucket_location.php} +2 -1
  20. inc/lightbox/index.html +0 -0
  21. inc/lightbox/{minify_recommendations.phtml → minify_recommendations.php} +3 -2
  22. inc/lightbox/{self_test.phtml → self_test.php} +18 -0
  23. inc/lightbox/{support_us.phtml → support_us.php} +5 -3
  24. inc/mime/all.php +1 -0
  25. inc/mime/cssjs.php +2 -1
  26. inc/mime/index.html +0 -0
  27. inc/mime/other.php +15 -11
  28. inc/options/{about.phtml → about.php} +9 -8
  29. inc/options/{browsercache.phtml → browsercache.php} +25 -20
  30. inc/options/{cdn.phtml → cdn.php} +25 -31
  31. inc/options/cdn/{azure.phtml → azure.php} +4 -3
  32. inc/options/cdn/{cf.phtml → cf.php} +4 -3
  33. inc/options/cdn/{cf2.phtml → cf2.php} +4 -3
  34. inc/options/cdn/common/{cnames.phtml → cnames.php} +13 -12
  35. inc/options/cdn/common/index.html +0 -0
  36. inc/options/cdn/{cotendo.phtml → cotendo.php} +3 -2
  37. inc/options/cdn/edgecast.php +36 -0
  38. inc/options/cdn/{ftp.phtml → ftp.php} +4 -3
  39. inc/options/cdn/index.html +0 -0
  40. inc/options/cdn/{mirror.phtml → mirror.php} +3 -2
  41. inc/options/cdn/{netdna.phtml → netdna.php} +3 -2
  42. inc/options/cdn/{rscf.phtml → rscf.php} +4 -3
  43. inc/options/cdn/{s3.phtml → s3.php} +4 -3
  44. inc/options/common/{footer.phtml → footer.php} +0 -0
  45. inc/options/common/{header.phtml → header.php} +4 -2
  46. inc/options/common/{help.phtml → help.php} +2 -1
  47. inc/options/common/index.html +0 -0
  48. inc/options/{dbcache.phtml → dbcache.php} +12 -9
  49. inc/options/{faq.phtml → faq.php} +3 -2
  50. inc/options/faq.xml +2 -2
  51. inc/options/{general.phtml → general.php} +165 -143
  52. inc/options/index.html +0 -0
  53. inc/options/{install.phtml → install.php} +39 -38
  54. inc/options/{minify.phtml → minify.php} +26 -20
  55. inc/options/minify/{ccjs.phtml → ccjs.php} +1 -0
  56. inc/options/minify/{ccjs2.phtml → ccjs2.php} +6 -1
  57. inc/options/minify/{css.phtml → css.php} +1 -0
  58. inc/options/minify/{csstidy.phtml → csstidy.php} +5 -0
  59. inc/options/minify/{csstidy2.phtml → csstidy2.php} +5 -0
  60. inc/options/minify/{html.phtml → html.php} +1 -0
  61. inc/options/minify/{htmltidy.phtml → htmltidy.php} +1 -0
  62. inc/options/minify/{htmltidy2.phtml → htmltidy2.php} +1 -0
  63. inc/options/minify/index.html +0 -0
  64. inc/options/minify/{js.phtml → js.php} +1 -0
  65. inc/options/minify/{yuicss2.phtml → yuicss2.php} +2 -1
  66. inc/options/minify/{yuijs.phtml → yuijs.php} +1 -0
  67. inc/options/minify/{yuijs2.phtml → yuijs2.php} +2 -1
  68. inc/options/{mobile.phtml → mobile.php} +5 -3
  69. inc/options/{objectcache.phtml → objectcache.php} +11 -32
  70. inc/options/{pgcache.phtml → pgcache.php} +36 -17
  71. inc/options/{referrer.phtml → referrer.php} +5 -3
  72. inc/options/support.php +21 -0
  73. inc/options/support.phtml +0 -38
  74. inc/options/support/form.php +29 -0
  75. inc/options/support/{bug_report.phtml → form/bug_report.php} +1 -0
  76. inc/options/support/{phone_support.phtml → form/email_support.php} +5 -4
  77. inc/options/support/form/index.html +0 -0
  78. inc/options/support/{linux_config.phtml → form/linux_config.php} +1 -0
  79. inc/options/support/{new_feature.phtml → form/new_feature.php} +1 -0
  80. inc/options/support/{email_support.phtml → form/phone_support.php} +5 -4
  81. inc/options/support/{plugin_config.phtml → form/plugin_config.php} +1 -0
  82. inc/options/support/{theme_config.phtml → form/theme_config.php} +1 -0
  83. inc/options/support/index.html +0 -0
  84. inc/options/support/payment.php +25 -0
  85. inc/options/support/select.php +22 -0
  86. inc/options/support_payment.phtml +0 -35
  87. inc/options/support_select.phtml +0 -34
  88. inc/popup/{cdn_export_file.phtml → cdn_export_file.php} +6 -3
  89. inc/popup/{cdn_export_library.phtml → cdn_export_library.php} +4 -2
  90. inc/popup/{cdn_import_library.phtml → cdn_import_library.php} +7 -6
  91. inc/popup/{cdn_purge.phtml → cdn_purge.php} +5 -4
  92. inc/popup/{cdn_queue.phtml → cdn_queue.php} +9 -8
  93. inc/popup/{cdn_rename_domain.phtml → cdn_rename_domain.php} +6 -4
  94. inc/popup/common/{footer.phtml → footer.php} +0 -0
  95. inc/popup/common/{header.phtml → header.php} +8 -6
  96. inc/popup/common/index.html +0 -0
  97. inc/popup/index.html +0 -0
  98. inc/popup/{pagespeed_results.phtml → pagespeed_results.php} +4 -2
  99. inc/widget/index.html +0 -0
  100. inc/widget/latest.php +7 -0
  101. inc/widget/{latest.phtml → latest_ajax.php} +2 -1
  102. inc/widget/{latest_control.phtml → latest_control.php} +1 -0
  103. inc/widget/{pagespeed.phtml → pagespeed.php} +5 -2
  104. inc/widget/{pagespeed_control.phtml → pagespeed_control.php} +1 -0
  105. index.html +0 -0
  106. ini/.htaccess +3 -0
  107. ini/index.html +0 -0
  108. lib/.htaccess +3 -0
  109. lib/CF/cacert.pem +3113 -3113
  110. lib/CF/cloudfiles.php +2149 -2147
  111. lib/CF/cloudfiles_exceptions.php +41 -41
  112. lib/CF/cloudfiles_http.php +1347 -1347
  113. lib/CF/index.html +0 -0
  114. lib/CSSTidy/class.csstidy.php +999 -999
  115. lib/CSSTidy/class.csstidy_optimise.php +784 -808
db/mssql.php DELETED
@@ -1,1255 +0,0 @@
1
- <?php
2
-
3
- /*
4
-
5
- http://code.google.com/p/wordpress-mssql/
6
-
7
- Contributors: Aizu Ikmal Ahmad & Iwani Khalid
8
- Requires at least: 2.3.0
9
- Tested up to: 2.7.1
10
- Development Status: Alpha
11
- Database Abstraction Class: ezSQL by Justin Vincent (http://php.justinvincent.com)
12
-
13
- How to install MS-SQL support for Wordpress
14
-
15
- 1. Download Wordpress ( http://wordpress.org/wordpress-2.7.1-IIS-RC1.zip )
16
- 2. Then, upload it on your webhosting that supports MSSQL and IIS like how you would usually do it
17
- 3. Download our Magic Plugin at ( http://code.google.com/p/wordpress-mssql/ )
18
- 4. Then upload that db.php to your wp-contents folder
19
- 5. Edit the MSSQL database setting in db.php file according to your MSSQL settings 6. You're done :D
20
-
21
- At this moment, this workaround works for these functions, to where we have debugged and tested
22
-
23
- * Basic submit, edit, manage posts and pages
24
- * Comments system
25
- * Dynamic sidebar
26
- * Changing themes
27
- * Installing plugins
28
- * Long text retrieval
29
-
30
- What we didn't have time to debug
31
-
32
- * Pagination
33
- * Categories > Posts retrieval
34
- * Dates / Time of posts
35
- * Others which we look forward to debug later :D
36
-
37
- */
38
-
39
- // ==================================================================
40
- // Author: Justin Vincent (justin@visunet.ie)
41
- // Web: http://php.justinvincent.com
42
- // Name: ezSQL
43
- // Desc: Class to make it very easy to deal with MS SQL database connections.
44
- //
45
- // N.B. ezSQL was converted for use with MS SQL
46
- // by Tom De Bruyne (tom@challenge.be).
47
- //
48
- // !! IMPORTANT !!
49
- //
50
- // Please send me a mail telling me what you think of ezSQL
51
- // and what your using it for!! Cheers. [ justin@visunet.ie ]
52
- //
53
- // ==================================================================
54
- // User Settings -- CHANGE HERE
55
-
56
- ini_set ('mssql.textlimit','2147483647');
57
- ini_set ('mssql.textsize','2147483647');
58
-
59
- define("EZSQL_DB_USER", "tretinoin_wpuser"); // <-- MS SQL Server db user
60
- define("EZSQL_DB_PASSWORD", "83h93hdi."); // <-- MS SQL Server db password
61
- define("EZSQL_DB_NAME", "tretinoin_wordpress"); // <-- MS SQL Server db pname
62
- define("EZSQL_DB_HOST", "lamp2win"); // <-- MS SQL Server server host
63
-
64
- // ==================================================================
65
- // ezSQL Constants
66
- define("EZSQL_VERSION","1.26");
67
- define("OBJECT","OBJECT",true);
68
- define("ARRAY_A","ARRAY_A",true);
69
- define("ARRAY_N","ARRAY_N",true);
70
-
71
- // ==================================================================
72
- // The Main Class
73
-
74
- class W3_Db_Driver {
75
-
76
- var $debug_called;
77
- var $vardump_called;
78
- var $show_errors = false;
79
- var $num_queries = 0;
80
- var $debug_all = false;
81
- var $last_query;
82
- var $col_info;
83
-
84
- var $suppress_errors = false;
85
- var $last_error = '';
86
- var $queries;
87
- var $prefix = '';
88
- var $ready = false;
89
- var $posts;
90
- var $users;
91
- var $categories;
92
- var $post2cat;
93
- var $comments;
94
- var $links;
95
- var $options;
96
- var $postmeta;
97
- var $usermeta;
98
- var $terms;
99
- var $term_taxonomy;
100
- var $term_relationships;
101
- var $tables = array('users', 'usermeta', 'posts', 'categories', 'post2cat', 'comments', 'links', 'link2cat', 'options',
102
- 'postmeta', 'terms', 'term_taxonomy', 'term_relationships');
103
-
104
- var $charset;
105
- var $collate;
106
-
107
-
108
-
109
-
110
- // ==================================================================
111
- // DB Constructor - connects to the server and selects a database
112
-
113
-
114
-
115
- function W3_Db_Driver($dbuser, $dbpassword, $dbname, $dbhost)
116
- {
117
-
118
- $this->dbh = mssql_connect($dbhost, $dbuser, $dbpassword);
119
-
120
- if ( ! $this->dbh ) {
121
- $this->print_error("<ol><b>Error establishing a database connection!</b><li>Are you sure you have the correct user/password?<li>Are you sure that you have typed the correct hostname?<li>Are you sure that the database server is running?</ol>");
122
- }
123
-
124
- $this->select($dbname);
125
-
126
- }
127
-
128
- // ==================================================================
129
- // Select a DB (if another one needs to be selected)
130
-
131
- function select($db)
132
- {
133
- mssql_select_db ($db);
134
- }
135
-
136
-
137
- // ==================================================================
138
- // Basic Query - see docs for more detail
139
-
140
- function query($query)
141
- {
142
-
143
- $query = trim($query);
144
- $query = str_replace('`',"'",$query);
145
-
146
- $query = str_replace('\012',"\n",$query);
147
- $query = str_replace('\015',"\r",$query);
148
-
149
- //$query = str_replace("\n",'',$query);
150
- //$query = str_replace("\r",'',$query);
151
-
152
- //$query = $this->escape($query);
153
- //$query = str_replace('"','\"',$query);
154
- //$query = str_replace("'","\'",$query);
155
-
156
-
157
- if(substr($query,0,7) == 'SELECT '){
158
-
159
- dbug($query,'SELECT : ORIGINAL QUERY ::::::: ','orange');
160
-
161
- $query_arr = explode('LIMIT',$query);
162
- if($query_arr[0] AND $query_arr[1]){
163
-
164
- $query_one = str_replace('SELECT ','',$query_arr[0]);
165
-
166
- $top_arr = explode(' ',$query_arr[1]);
167
-
168
- if($top_arr[1] && $top_arr[2]){
169
- $query = 'SELECT TOP '.$top_arr[2].' '.$query_one;
170
- }else{
171
- $query = 'SELECT TOP '.$top_arr[1].' '.$query_one;
172
- }
173
-
174
-
175
-
176
- /*
177
-
178
- // TO BE DEVELOP
179
-
180
- //LIMIT 1, 3
181
-
182
- SELECT * FROM (
183
- SELECT TOP 3 * FROM
184
- (SELECT TOP (1+3) * FROM wp_posts WHERE 1=1 AND post_type = 'post' AND (post_status = 'publish' OR post_status = 'private') ORDER BY post_date DESC)
185
- AS table1 ORDER BY post_date ASC
186
- ) AS table2 ORDER BY post_date DESC
187
-
188
- */
189
-
190
- //pre($query_arr);
191
- //exit();
192
-
193
-
194
- }
195
-
196
-
197
- if(substr($query,0,23) == "SELECT TOP 1 comment_ID"){
198
- $query = str_replace(' = ',' = ',$query);
199
- }
200
-
201
-
202
- /* DUMP DIRTY SWEPT TEST */
203
- $query = str_replace('wp_posts.','',$query);
204
-
205
-
206
- /*
207
- hacks for query;
208
- - SELECT * FROM wp_posts WHERE (post_type = 'page' AND post_status = 'publish') ORDER BY menu_order, post_title ASC
209
- - SELECT * FROM wp_posts WHERE 1=1 AND post_type = 'page' AND (post_status = 'publish' OR post_status = 'future' OR post_status = 'draft' OR post_status = 'pending' OR post_status = 'private') ORDER BY menu_order,post_title asc
210
- notes;
211
- somehow Wordpress developer create this 'post_title' date-type as 'text' in database. the post_title should be varchar since the amount of character in title is generally less then 255 char.
212
- and in ms-sql, text cannot be sorted. so this is a big mistake. haihhh...
213
- */
214
- $pattern = '/post_title asc/is';
215
- $replacement = 'cast(post_title as varchar(500)) ASC';
216
- $query = preg_replace($pattern, $replacement, $query);
217
-
218
-
219
-
220
-
221
- /*
222
- hacks for query;
223
- - SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM wp_posts WHERE post_type = 'post' ORDER BY post_date DESC
224
- notes;
225
- this is one another hacks for SELECT DISTINCT call.
226
- The above query tries to sort by the column post_date. Because the keyword DISTINCT is also specified, column post_date must appear in the SELECT list
227
- expected return;
228
- - SELECT DISTINCT post_date, YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM wp_posts WHERE post_type = 'post' ORDER BY post_date DESC
229
- */
230
- if(substr($query,0,15) == "SELECT DISTINCT"){
231
- $string = $query;
232
- $pattern = '/SELECT DISTINCT (.*)? ORDER BY (.*)? (asc|desc)/i';
233
- $replacement = 'cast(post_title as varchar(500)) ASC';
234
- preg_match_all($pattern, $string, $result);
235
- $order_by_col = $result[2][0];
236
- $col_calls = $result[1][0];
237
- $order_by_prop = $result[3][0];
238
- $query = 'SELECT DISTINCT '.$order_by_col.', '.$col_calls.' ORDER BY '.$order_by_col.' '.$order_by_prop;
239
- }
240
-
241
-
242
-
243
-
244
- /*
245
- hacks for query;
246
- - SELECT user_id FROM wp_usermeta WHERE meta_key = 'wp_user_level' AND meta_value != '0'
247
- notes;
248
- replace != into NOT <col_name> LIKE
249
- expected return;
250
- - SELECT user_id FROM wp_usermeta WHERE meta_key = 'wp_user_level' AND NOT meta_value LIKE '0'
251
- */
252
- $pattern = "/ (?:[a-z][a-z0-9_]*)? \!\= /is";
253
- preg_match_all($pattern, $query, $result);
254
- $result_arr = $result[0];
255
- $query = str_replace('!=','',$query);
256
- foreach($result_arr as $result_item){
257
- $result_item = str_replace('!=','',$result_item);
258
- $result_item = trim($result_item);
259
- $query = str_replace($result_item,' NOT '.$result_item.' LIKE ',$query);
260
- }
261
-
262
-
263
-
264
- /*
265
- hacks for;
266
- - SQL have 'GROUP BY'
267
- - SELECT DISTINCT post_date, YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish
268
- GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC
269
- */
270
- if (preg_match("/GROUP BY/i", $query)) {
271
- $pattern = '/SELECT (.*) GROUP BY (.*)? ORDER BY (.*)/i';
272
- preg_match($pattern, $string, $output);
273
-
274
- $query0 = 'SELECT '.$output[1].' ORDER BY '.$output[3];
275
- }
276
-
277
-
278
- $query = str_replace('SQL_CALC_FOUND_ROWS',' ',$query);
279
- if (preg_match("/SELECT FOUND_ROWS()/i", $query)) {
280
- $last_query = $this->last_query;
281
- $last_query_one_arr = explode('TOP',$last_query);
282
- $last_query_two = trim($last_query_one_arr[1]);
283
- $last_query_three_arr = explode(' ',$last_query_two);
284
- $last_query_four = str_replace($last_query_three_arr[0],'',$last_query_two);
285
- $query = 'SELECT '.$last_query_four;
286
- }
287
-
288
- dbug($query,'SELECT : MODDED QUERY :::::::: ','orange');
289
-
290
- }elseif(substr($query,0,7) == 'INSERT '){
291
-
292
- dbug($query,'INSERT : ORIGINAL QUERY ::::::::: ','purple');
293
-
294
- $pattern = '/INSERT INTO (.*)?\((.*)\).*?VALUES.*?\((.*)\)/is';
295
- preg_match_all($pattern, $query, $output);
296
- $insert_table = trim($output[1][0]);
297
- $insert_cols = trim($output[2][0]);
298
- $insert_values = trim($output[3][0]);
299
-
300
- /* STRIP QUOTE FROM COLS NAME */
301
- $insert_cols = str_replace("'",'',$insert_cols);
302
-
303
- $query = $this->prepare($query);
304
-
305
- /* PROCESS THE $insert_values. NEED TO REPLACE THE INNER QUOTES */
306
- preg_match_all("/([0-9]+|\'(.*?)\'[ ]*?),/is", $insert_values.',', $output);
307
-
308
- $insert_values_arr = array(); //PREPARE THE NEW FRESH VALUES
309
- foreach($output[0] as $insert_values_item){
310
- if(substr(trim($insert_values_item),0,1) == "'"){
311
- $insert_values_item = substr($insert_values_item,1); // TAKE OUT THE FIRST 1 CHAR, WHICH IS QUOTE
312
- }
313
- $insert_values_item = trim($insert_values_item); // TRIM THE WHITESPACE
314
- if(substr(trim($insert_values_item),-1) == ","){
315
- $insert_values_item = substr($insert_values_item,0,-1); // TAKE OUT THE LAST 1 CHAR, WHICH IS COMMA
316
- }
317
- if(substr(trim($insert_values_item),-1) == "'"){
318
- $insert_values_item = substr($insert_values_item,0,-1); // TAKE OUT THE LAST 1 CHAR, WHICH IS QUOTE
319
- }
320
- $insert_values_item = str_replace("'","''",$insert_values_item); // NOW WE PUT THE EXTRA QUOTE ON IT
321
- $insert_values_item = trim($insert_values_item); // TRIM THE WHITESPACE
322
- $insert_values_item = "'".$insert_values_item."'"; // WRAP THE VALUES WITH OUR SINGLE-QUOTE
323
- $insert_values_arr[] = $insert_values_item;
324
- }
325
-
326
- $insert_values = implode(',',$insert_values_arr);
327
-
328
-
329
- /* CONSTRUCT NEW INSERT CALL */
330
- $query = 'INSERT INTO '.$insert_table.' ('.$insert_cols.') VALUES ('.$insert_values.');';
331
-
332
-
333
- dbug($query,'INSERT : MODDED QUERY :::::::::: ','purple');
334
-
335
- }elseif(substr($query,0,7) == 'UPDATE '){
336
-
337
-
338
- dbug($query,'UPDATE : ORIGINAL QUERY ::::::::: ','blue');
339
-
340
-
341
- $pattern = '/UPDATE ([A-Za-z0-9_-]+) SET (.*)? WHERE (.*)?/is';
342
- preg_match_all($pattern, $query, $output);
343
- $update_table = trim($output[1][0]);
344
- $update_values = trim($output[2][0]);
345
- $update_where = trim($output[3][0]);
346
-
347
- preg_match_all("/(.*?)[ *]?=[ *]?(\'(.*?)\'|[0-9]+),/is", $update_values.',', $output_vals);
348
-
349
- $update_vals_colname = $output_vals[1];
350
- $update_vals_values = $output_vals[2];
351
-
352
-
353
- $update_vals_colname_mod = array();
354
- foreach($update_vals_colname as $update_vals_colname_item){
355
- $update_vals_colname_item = str_replace("'",'',$update_vals_colname_item); // GREEDY REPLACE ALL QUOTES. NO QUOTES ALLOWED IN COL NAME
356
- $update_vals_colname_item = trim($update_vals_colname_item); // TRIM THE WHITESPACE
357
- $update_vals_colname_mod[] = $update_vals_colname_item;
358
- }
359
-
360
- $update_vals_values_mod = array();
361
- foreach($update_vals_values as $update_vals_values_item){
362
- if(substr(trim($update_vals_values_item),0,1) == "'"){
363
- $update_vals_values_item = substr($update_vals_values_item,1); // TAKE OUT THE FIRST 1 CHAR, WHICH IS QUOTE
364
- }
365
- if(substr(trim($update_vals_values_item),-1) == "'"){
366
- $update_vals_values_item = substr($update_vals_values_item,0,-1); // TAKE OUT THE LAST 1 CHAR, WHICH IS QUOTE
367
- }
368
- $update_vals_values_item = trim($update_vals_values_item); // TRIM THE WHITESPACE
369
- $update_vals_values_item = str_replace("'","''",$update_vals_values_item); // ADD ADDITIONAL QUOTE TO ESCAPE IT IN MSSQL
370
- $update_vals_values_mod[] = $update_vals_values_item;
371
- }
372
-
373
- $update_values_modded = array_combine($update_vals_colname_mod,$update_vals_values_mod);
374
-
375
- $update_values = '';
376
- $update_values_prepare_arr = '';
377
- $update_values_item = '';
378
- foreach($update_values_modded as $update_values_item_colname => $update_values_item_value){
379
- $update_values_prepare_arr[] = $update_values_item_colname." = '".$update_values_item_value."'";
380
- }
381
-
382
-
383
- $update_values = implode(',',$update_values_prepare_arr);
384
-
385
-
386
-
387
-
388
-
389
- /* CONSTRUCT NEW UPDATE CALL */
390
- $query = 'UPDATE '.$update_table.' SET '.$update_values.' WHERE '.$update_where.';';
391
-
392
-
393
-
394
-
395
-
396
-
397
-
398
-
399
-
400
-
401
- dbug($query,'UPDATE : MODDED QUERY :::::::::: ','blue');
402
-
403
- }elseif(substr($query,0,7) == 'DELETE '){
404
-
405
-
406
-
407
- dbug($query,'DELETE','orange');
408
-
409
- }elseif(substr($query,0,7) == 'CREATE '){
410
-
411
- $query_two = str_replace('auto_increment','IDENTITY(1,1)',$query);
412
- $query_two = str_replace('tinytext','text',$query_two);
413
- $query_two = str_replace('longtext','text',$query_two);
414
- $query_two = str_replace('mediumtext','text',$query_two);
415
- $query_two = str_replace('unsigned ','',$query_two);
416
- $query_three = preg_replace('/bigint\(\d+\)/i','int',$query_two);
417
- $query_three = preg_replace('/int\(\d+\)/i','int',$query_three);
418
- $query_four_arr = explode('PRIMARY KEY',$query_three);
419
- $query_five = $query_four_arr[0].' ';
420
- $query_six = $query_four_arr[1];
421
- $query_seven_arr = explode('),',$query_six);
422
- $query_eight_arr = explode('(',$query);
423
- $query_nine = trim($query_eight_arr[0]);
424
- $query_ten = str_replace($query_nine,'',$query_five);
425
- $table_name = trim(str_replace('CREATE TABLE','',$query_nine));
426
-
427
-
428
- $create_table_header = "
429
- IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[tretinoin_wpuser].[".$table_name."]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
430
- DROP TABLE [tretinoin_wpuser].[".$table_name."]
431
- GO
432
- CREATE TABLE [tretinoin_wpuser].[".$table_name."]";
433
-
434
- $create_table_header_simple = "CREATE TABLE [tretinoin_wpuser].[".$table_name."]
435
-
436
- ";
437
-
438
- $query = $create_table_header_simple . $query_ten . ' PRIMARY KEY ' . $query_seven_arr[0] .'))';
439
-
440
- dbug($query,'CREATE','purple');
441
-
442
- }elseif(substr($query,0,5) == 'SHOW '){
443
-
444
- $query = str_replace('SHOW TABLES;','',$query);
445
-
446
- dbug($query,'SHOW','yellow');
447
-
448
- }else{
449
-
450
-
451
- dbug($query);
452
-
453
- }
454
-
455
-
456
-
457
- // For reg expressions
458
- $query = trim($query);
459
-
460
- // Flush cached values..
461
- $this->flush();
462
-
463
- // Log how the function was called
464
- $this->func_call = "\$db->query(\"$query\")";
465
-
466
- // Keep track of the last query for debug..
467
- $this->last_query = $query;
468
-
469
- // Perform the query via std mssql_query function..
470
-
471
-
472
- if(substr($query,0,7) == 'SELECT '){
473
- $this->result_check = @mssql_query($query, $this->dbh);
474
- }elseif(substr($query,0,7) == 'INSERT '){
475
-
476
- }elseif(substr($query,0,7) == 'UPDATE '){
477
- $this->result_check = @mssql_query($query, $this->dbh);
478
- }elseif(substr($query,0,7) == 'DELETE '){
479
-
480
- }elseif(substr($query,0,7) == 'CREATE '){
481
-
482
- }elseif(substr($query,0,5) == 'SHOW '){
483
-
484
- }
485
-
486
-
487
-
488
-
489
- // Unfortunately, PHP fuctions for MS SQL currently don't offer a decent way
490
- // to retrieve errors from MS SQL
491
- // Make sure not to run a query between the actual query and this one !
492
-
493
- $get_errorcode = "SELECT @@ERROR as errorcode";
494
- $error_res = @mssql_query($get_errorcode, $this->dbh);
495
- $errorcode = @mssql_result($error_res, 0, "errorcode");
496
-
497
- // ERROR LIST
498
- // 402 : The data types text and varchar are incompatible in the equal to operator.
499
- // 306 : The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.
500
-
501
-
502
- if ($errorcode == '402') {
503
- $query_two = str_replace(' = ',' LIKE ',$query);
504
-
505
-
506
- /* NEED MORE IMPROVEMENT HERE */
507
-
508
-
509
-
510
- }else{
511
- $query_two = $query;
512
- }
513
- dbug($query,$errorcode,'green');
514
-
515
-
516
- $this->result = @mssql_query($query_two, $this->dbh);
517
- $this->num_queries++;
518
-
519
-
520
- // If there was an insert, delete or update see how many rows were affected
521
- // (Also, If there there was an insert take note of the last OID
522
- $query_type = array("insert","delete","update","replace");
523
-
524
- // loop through the above array
525
- foreach ( $query_type as $word )
526
- {
527
- // This is true if the query starts with insert, delete or update
528
- if ( preg_match("/^$word\s+/i",$query) )
529
- {
530
- $this->rows_affected = @mssql_rows_affected ($this->dbh);
531
-
532
- // This gets the insert ID
533
- if ( $word == "insert" || $word == "replace" )
534
- {
535
- $get_last_ident = "SELECT @@IDENTITY as id";
536
- $last_res = @mssql_query($get_last_ident, $this->dbh);
537
- $this->insert_id = @mssql_result($last_res, 0, "id");
538
-
539
- // If insert id then return it - true evaluation
540
- return $this->insert_id;
541
- }
542
-
543
- // Set to false if there was no insert id
544
- $this->result = false;
545
- }
546
- }
547
-
548
-
549
- if ($errorcode <> 0) {
550
- // there is an error
551
- $this->print_error();
552
- }
553
- else
554
- {
555
-
556
- // =======================================================
557
- // Take note of column info
558
-
559
- $i=0;
560
- while ($i < @mssql_num_fields($this->result))
561
- {
562
- $this->col_info[$i]->name = @mssql_field_name($this->result,$i);
563
- $this->col_info[$i]->type = @mssql_field_type($this->result,$i);
564
- $this->col_info[$i]->size = @mssql_field_length($this->result,$i);
565
- $i++;
566
- }
567
-
568
- // =======================================================
569
- // Store Query Results
570
-
571
- $i=0;
572
- while ( $row_arr = @mssql_fetch_array($this->result) )
573
- {
574
-
575
- $row = array_to_object($row_arr);
576
- $this->last_result[$i] = $row;
577
-
578
- // Store relults as an objects within main array
579
-
580
-
581
- $i++;
582
- }
583
-
584
- if($i == 0){
585
- $this->last_result = array();
586
- }
587
-
588
- //pre($this->last_result);
589
-
590
- // Log number of rows the query returned
591
- $this->num_rows = $i;
592
-
593
- //}
594
-
595
- @mssql_free_result($this->result);
596
-
597
- // If this was a select..
598
- if ( preg_match("/^(select|show|desc)\s+/i",$query) )
599
- {
600
-
601
- // If debug ALL queries
602
- $this->debug_all ? $this->debug() : null ;
603
-
604
- // If there were results then return true for $db->query
605
- if ( $i )
606
- {
607
- return true;
608
- }
609
- else
610
- {
611
- return false;
612
- }
613
- }
614
- else
615
- {
616
- // If debug ALL queries
617
- $this->debug_all ? $this->debug() : null ;
618
-
619
- // Update insert etc. was good..
620
- return true;
621
- }
622
-
623
- }
624
- }
625
-
626
-
627
-
628
-
629
- // ====================================================================
630
- // Format a string correctly for safe insert under all PHP conditions
631
-
632
- function escape($str)
633
- {
634
-
635
- // This deals with quote escaping
636
- //$str = str_replace("'","''",$str);
637
- //$str = str_replace("\'","'",$str);
638
-
639
- //$str = mysql_real_escape_string($str);
640
-
641
- //$str = str_replace("'", "''", $str);
642
- //$str = addslashes($str);
643
-
644
- //dbug($str,'ESCAPE RUN TWICE','red');
645
-
646
- // These values need to be escaped for ms sql
647
- $escape = array ( "\n"=>"\\\\012","\r"=>"\\\\015");
648
-
649
- // Firstly unescape
650
- /*
651
- foreach ( $escape as $match => $replace )
652
- {
653
- $str = str_replace($match,$replace,$str);
654
- }
655
- */
656
- return $str;
657
-
658
- }
659
-
660
- // ==================================================================
661
- // Print SQL/DB error.
662
-
663
- function print_error($str = "")
664
- {
665
- // All erros go to the global error array $EZSQL_ERROR..
666
- global $EZSQL_ERROR;
667
-
668
- // if no special error, take last mssql error
669
- if ( !$str ) $str = mssql_get_last_message();
670
-
671
- // Log this error to the global array..
672
- $EZSQL_ERROR[] = array
673
- (
674
- "query" => $this->last_query,
675
- "error_str" => $str
676
- );
677
-
678
- // Is error output turned on or not..
679
- if ( $this->show_errors )
680
- {
681
- // If there is an error then take note of it
682
- /*
683
- print "<blockquote><font face=arial size=2 color=ff0000>";
684
- print "<b>SQL/DB Error --</b> ";
685
- print "[<font color=000000>".$this->last_query."</font>]";
686
- print "[<font color=000077>$str</font>]";
687
- print "</font></blockquote>";
688
- */
689
-
690
- dbug($this->last_query.'<br />'.$str,'ERROR','red');
691
- return false;
692
- }
693
- else
694
- {
695
- return false;
696
- }
697
-
698
-
699
-
700
-
701
-
702
- }
703
-
704
- // ==================================================================
705
- // Turn error handling on or off..
706
-
707
- function show_errors()
708
- {
709
- $this->show_errors = true;
710
- }
711
-
712
- function hide_errors()
713
- {
714
- $this->show_errors = false;
715
- }
716
-
717
- // ==================================================================
718
- // Kill cached query results
719
-
720
- function flush()
721
- {
722
-
723
- // Get rid of these
724
- $this->last_result = null;
725
- $this->col_info = null;
726
- $this->last_query = null;
727
-
728
- }
729
-
730
-
731
-
732
- // ==================================================================
733
- // Get one variable from the DB - see docs for more detail
734
-
735
- function get_var($query=null,$x=0,$y=0)
736
- {
737
-
738
- // Log how the function was called
739
- $this->func_call = "\$db->get_var(\"$query\",$x,$y)";
740
-
741
- // If there is a query then perform it if not then use cached results..
742
- if ( $query )
743
- {
744
- $this->query($query);
745
- }
746
-
747
- // Extract var out of cached results based x,y vals
748
- if ( $this->last_result[$y] )
749
- {
750
- $values = array_values(get_object_vars($this->last_result[$y]));
751
- }
752
-
753
- // If there is a value return it else return null
754
- return (isset($values[$x]) && $values[$x]!=='')?$values[$x]:null;
755
- }
756
-
757
- // ==================================================================
758
- // Get one row from the DB - see docs for more detail
759
-
760
- function get_row($query=null,$output=OBJECT,$y=0)
761
- {
762
-
763
- // Log how the function was called
764
- $this->func_call = "\$db->get_row(\"$query\",$output,$y)";
765
-
766
- // If there is a query then perform it if not then use cached results..
767
- if ( $query )
768
- {
769
- $this->query($query);
770
- }
771
-
772
- // If the output is an object then return object using the row offset..
773
- if ( $output == OBJECT )
774
- {
775
- return $this->last_result[$y]?$this->last_result[$y]:null;
776
- }
777
- // If the output is an associative array then return row as such..
778
- elseif ( $output == ARRAY_A )
779
- {
780
- return $this->last_result[$y]?get_object_vars($this->last_result[$y]):null;
781
- }
782
- // If the output is an numerical array then return row as such..
783
- elseif ( $output == ARRAY_N )
784
- {
785
- return $this->last_result[$y]?array_values(get_object_vars($this->last_result[$y])):null;
786
- }
787
- // If invalid output type was specified..
788
- else
789
- {
790
- $this->print_error(" \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N");
791
- }
792
-
793
- }
794
-
795
- // ==================================================================
796
- // Function to get 1 column from the cached result set based in X index
797
- // se docs for usage and info
798
-
799
- function get_col($query=null,$x=0)
800
- {
801
-
802
- // If there is a query then perform it if not then use cached results..
803
- if ( $query )
804
- {
805
- $this->query($query);
806
- }
807
-
808
- // Extract the column values
809
- for ( $i=0; $i < count($this->last_result); $i++ )
810
- {
811
- $new_array[$i] = $this->get_var(null,$x,$i);
812
- }
813
-
814
- if($i == 0){
815
- $new_array = array();
816
- }
817
-
818
- return $new_array;
819
- }
820
-
821
- // ==================================================================
822
- // Return the the query as a result set - see docs for more details
823
-
824
- function get_results($query=null, $output = OBJECT)
825
- {
826
-
827
- // Log how the function was called
828
- $this->func_call = "\$db->get_results(\"$query\", $output)";
829
-
830
- // If there is a query then perform it if not then use cached results..
831
- if ( $query )
832
- {
833
- $this->query($query);
834
- }
835
-
836
- // Send back array of objects. Each row is an object
837
- if ( $output == OBJECT )
838
- {
839
-
840
- $out = get_object_vars($this->last_result);
841
-
842
- return $this->last_result;
843
- }
844
- elseif ( $output == ARRAY_A || $output == ARRAY_N )
845
- {
846
- if ( $this->last_result )
847
- {
848
- $i=0;
849
- foreach( $this->last_result as $row )
850
- {
851
-
852
- $new_array[$i] = get_object_vars($row);
853
-
854
- if ( $output == ARRAY_N )
855
- {
856
- $new_array[$i] = array_values($new_array[$i]);
857
- }
858
-
859
- $i++;
860
- }
861
-
862
- return $new_array;
863
- }
864
- else
865
- {
866
- return null;
867
- }
868
- }
869
- }
870
-
871
-
872
- // ==================================================================
873
- // Function to get column meta data info pertaining to the last query
874
- // see docs for more info and usage
875
-
876
- function get_col_info($info_type="name",$col_offset=-1)
877
- {
878
-
879
- if ( $this->col_info )
880
- {
881
- if ( $col_offset == -1 )
882
- {
883
- $i=0;
884
- foreach($this->col_info as $col )
885
- {
886
- $new_array[$i] = $col->{$info_type};
887
- $i++;
888
- }
889
- return $new_array;
890
- }
891
- else
892
- {
893
- return $this->col_info[$col_offset]->{$info_type};
894
- }
895
-
896
- }
897
-
898
- }
899
-
900
-
901
- // ==================================================================
902
- // Dumps the contents of any input variable to screen in a nicely
903
- // formatted and easy to understand way - any type: Object, Var or Array
904
-
905
- function vardump($mixed='')
906
- {
907
-
908
- echo "<p><table><tr><td bgcolor=ffffff><blockquote><font color=000090>";
909
- echo "<pre><font face=arial>";
910
-
911
- if ( ! $this->vardump_called )
912
- {
913
- echo "<font color=800080><b>ezSQL</b> (v".EZSQL_VERSION.") <b>Variable Dump..</b></font>\n\n";
914
- }
915
-
916
- $var_type = gettype ($mixed);
917
- print_r(($mixed?$mixed:"<font color=red>No Value / False</font>"));
918
- echo "\n\n<b>Type:</b> " . ucfirst($var_type) . "\n";
919
- echo "<b>Last Query</b> [$this->num_queries]<b>:</b> ".($this->last_query?$this->last_query:"NULL")."\n";
920
- echo "<b>Last Function Call:</b> " . ($this->func_call?$this->func_call:"None")."\n";
921
- echo "<b>Last Rows Returned:</b> ".count($this->last_result)."\n";
922
- echo "</font></pre></font></blockquote></td></tr></table>".$this->donation();
923
- echo "\n<hr size=1 noshade color=dddddd>";
924
-
925
- $this->vardump_called = true;
926
-
927
- }
928
-
929
- // Alias for the above function
930
- function dumpvar($mixed)
931
- {
932
- $this->vardump($mixed);
933
- }
934
-
935
- // ==================================================================
936
- // Displays the last query string that was sent to the database & a
937
- // table listing results (if there were any).
938
- // (abstracted into a seperate file to save server overhead).
939
-
940
- function debug()
941
- {
942
-
943
- echo "<blockquote>";
944
-
945
- // Only show ezSQL credits once..
946
- if ( ! $this->debug_called )
947
- {
948
- echo "<font color=800080 face=arial size=2><b>ezSQL</b> (v".EZSQL_VERSION.") <b>Debug..</b></font><p>\n";
949
- }
950
- echo "<font face=arial size=2 color=000099><b>Query</b> [$this->num_queries] <b>--</b> ";
951
- echo "[<font color=000000><b>$this->last_query</b></font>]</font><p>";
952
-
953
- echo "<font face=arial size=2 color=000099><b>Query Result..</b></font>";
954
- echo "<blockquote>";
955
-
956
- if ( $this->col_info )
957
- {
958
-
959
- // =====================================================
960
- // Results top rows
961
-
962
- echo "<table cellpadding=5 cellspacing=1 bgcolor=555555>";
963
- echo "<tr bgcolor=eeeeee><td nowrap valign=bottom><font color=555599 face=arial size=2><b>(row)</b></font></td>";
964
-
965
-
966
- for ( $i=0; $i < count($this->col_info); $i++ )
967
- {
968
- echo "<td nowrap align=left valign=top><font size=1 color=555599 face=arial>{$this->col_info[$i]->type} {$this->col_info[$i]->max_length}</font><br><span style='font-family: arial; font-size: 10pt; font-weight: bold;'>{$this->col_info[$i]->name}</span></td>";
969
- }
970
-
971
- echo "</tr>";
972
-
973
- // ======================================================
974
- // print main results
975
-
976
- if ( $this->last_result )
977
- {
978
-
979
- $i=0;
980
- foreach ( $this->get_results(null,ARRAY_N) as $one_row )
981
- {
982
- $i++;
983
- echo "<tr bgcolor=ffffff><td bgcolor=eeeeee nowrap align=middle><font size=2 color=555599 face=arial>$i</font></td>";
984
-
985
- foreach ( $one_row as $item )
986
- {
987
- echo "<td nowrap><font face=arial size=2>$item</font></td>";
988
- }
989
-
990
- echo "</tr>";
991
- }
992
-
993
- } // if last result
994
- else
995
- {
996
- echo "<tr bgcolor=ffffff><td colspan=".(count($this->col_info)+1)."><font face=arial size=2>No Results</font></td></tr>";
997
- }
998
-
999
- echo "</table>";
1000
-
1001
- } // if col_info
1002
- else
1003
- {
1004
- echo "<font face=arial size=2>No Results</font>";
1005
- }
1006
-
1007
- echo "</blockquote></blockquote>".$this->donation()."<hr noshade color=dddddd size=1>";
1008
-
1009
-
1010
- $this->debug_called = true;
1011
- }
1012
-
1013
- // =======================================================
1014
- // Naughty little function to ask for some remuniration!
1015
-
1016
- function donation()
1017
- {
1018
- return "<font size=1 face=arial color=000000>If ezSQL has helped <a href=\"https://www.paypal.com/xclick/business=justin%40justinvincent.com&item_name=ezSQL&no_note=1&tax=0\" style=\"color: 0000CC;\">make a donation!?</a> &nbsp;&nbsp;[ go on! you know you want to! ]</font>";
1019
- }
1020
-
1021
-
1022
-
1023
-
1024
- /**
1025
- * Sets the table prefix for the WordPress .
1026
- *
1027
- * Also allows for the CUSTOM_USER_TABLE and CUSTOM_USER_META_TABLE to
1028
- * override the WordPress users and usersmeta tables.
1029
- *
1030
- * @since 2.5.0
1031
- *
1032
- * @param string $prefix Alphanumeric name for the new prefix.
1033
- * @return string Old prefix
1034
- */
1035
- function set_prefix($prefix) {
1036
-
1037
- if ( preg_match('|[^a-z0-9_]|i', $prefix) )
1038
- return new WP_Error('invalid_db_prefix', /*WP_I18N_DB_BAD_PREFIX*/'Invalid database prefix'/*/WP_I18N_DB_BAD_PREFIX*/);
1039
-
1040
- $old_prefix = $this->prefix;
1041
- $this->prefix = $prefix;
1042
-
1043
- foreach ( (array) $this->tables as $table )
1044
- $this->$table = $this->prefix . $table;
1045
-
1046
- if ( defined('CUSTOM_USER_TABLE') )
1047
- $this->users = CUSTOM_USER_TABLE;
1048
-
1049
- if ( defined('CUSTOM_USER_META_TABLE') )
1050
- $this->usermeta = CUSTOM_USER_META_TABLE;
1051
-
1052
- return $old_prefix;
1053
- }
1054
-
1055
-
1056
- /**
1057
- * Whether to suppress database errors.
1058
- *
1059
- * @param unknown_type $suppress
1060
- * @return unknown
1061
- */
1062
- function suppress_errors( $suppress = true ) {
1063
- $errors = $this->suppress_errors;
1064
- $this->suppress_errors = $suppress;
1065
- return $errors;
1066
- }
1067
-
1068
-
1069
- /**
1070
- * Escapes content by reference for insertion into the database, for security
1071
- *
1072
- * @since 2.3.0
1073
- *
1074
- * @param string $s
1075
- */
1076
- function escape_by_ref(&$s) {
1077
- $s = $this->escape($s);
1078
- }
1079
-
1080
- /**
1081
- * Generic function to determine if a database supports a particular feature
1082
- * @param string $db_cap the feature
1083
- * @param false|string|resource $dbh_or_table the databaese (the current database, the database housing the specified table, or the database of the mysql resource)
1084
- * @return bool
1085
- */
1086
- function has_cap( $db_cap ) {
1087
-
1088
-
1089
- return false;
1090
- }
1091
-
1092
- /**
1093
- * Insert an array of data into a table.
1094
- *
1095
- * @since 2.5.0
1096
- *
1097
- * @param string $table WARNING: not sanitized!
1098
- * @param array $data Should not already be SQL-escaped
1099
- * @return mixed Results of $this->query()
1100
- */
1101
- function insert($table, $data) {
1102
- $data = add_magic_quotes($data);
1103
- $fields = array_keys($data);
1104
- return $this->query("INSERT INTO $table (`" . implode('`,`',$fields) . "`) VALUES ('".implode("','",$data)."')");
1105
- }
1106
-
1107
- /**
1108
- * Prepares a SQL query for safe use, using sprintf() syntax.
1109
- *
1110
- * @link http://php.net/sprintf See for syntax to use for query string.
1111
- * @since 2.3.0
1112
- *
1113
- * @param null|string $args If string, first parameter must be query statement
1114
- * @param mixed $args,... If additional parameters, they will be set inserted into the query.
1115
- * @return null|string Sanitized query string
1116
- */
1117
- function prepare($args=null) {
1118
- if ( is_null( $args ) )
1119
- return;
1120
- $args = func_get_args();
1121
- $query = array_shift($args);
1122
- $query = str_replace("'%s'", '%s', $query); // in case someone mistakenly already singlequoted it
1123
- $query = str_replace('"%s"', '%s', $query); // doublequote unquoting
1124
- $query = str_replace('%s', "'%s'", $query); // quote the strings
1125
- array_walk($args, array(&$this, 'escape_by_ref'));
1126
- return @vsprintf($query, $args);
1127
- }
1128
-
1129
-
1130
-
1131
- /**
1132
- * Update a row in the table with an array of data.
1133
- *
1134
- * @since 2.5.0
1135
- *
1136
- * @param string $table WARNING: not sanitized!
1137
- * @param array $data Should not already be SQL-escaped
1138
- * @param array $where A named array of WHERE column => value relationships. Multiple member pairs will be joined with ANDs. WARNING: the column names are not currently sanitized!
1139
- * @return mixed Results of $this->query()
1140
- */
1141
- function update($table, $data, $where){
1142
- $data = add_magic_quotes($data);
1143
- $bits = $wheres = array();
1144
- foreach ( (array) array_keys($data) as $k )
1145
- $bits[] = "`$k` = '$data[$k]'";
1146
-
1147
- if ( is_array( $where ) )
1148
- foreach ( $where as $c => $v ){
1149
- $v = str_replace("'","'",$v);
1150
- //$wheres[] = "$c = '" . $this->escape( $v ) . "'";
1151
- $wheres[] = "$c = '" . $v . "'";
1152
- }
1153
- else
1154
- return false;
1155
-
1156
- return $this->query( "UPDATE $table SET " . implode( ', ', $bits ) . ' WHERE ' . implode( ' AND ', $wheres ) );
1157
- }
1158
-
1159
- /**
1160
- * Whether or not MySQL database is minimal required version.
1161
- *
1162
- * @since 2.5.0
1163
- * @uses $wp_version
1164
- *
1165
- * @return WP_Error
1166
- */
1167
- function check_database_version()
1168
- {
1169
- global $wp_version;
1170
- // Make sure the server has MySQL 4.0
1171
- /*
1172
- if ( version_compare($this->db_version(), '4.0.0', '<') )
1173
- return new WP_Error('database_version',sprintf(__('<strong>ERROR</strong>: WordPress %s requires MySQL 4.0.0 or higher'), $wp_version));
1174
-
1175
- */
1176
-
1177
- }
1178
-
1179
-
1180
-
1181
-
1182
-
1183
-
1184
-
1185
-
1186
-
1187
-
1188
-
1189
-
1190
-
1191
-
1192
-
1193
-
1194
-
1195
-
1196
-
1197
-
1198
-
1199
- }
1200
-
1201
- // automatically create a new $db object
1202
-
1203
- //$wpdb = new db(EZSQL_DB_USER, EZSQL_DB_PASSWORD, EZSQL_DB_NAME, EZSQL_DB_HOST);
1204
-
1205
-
1206
-
1207
-
1208
- function array_to_object($array = array()) {
1209
- if (!empty($array)) {
1210
- $data = false;
1211
-
1212
- foreach ($array as $akey => $aval) {
1213
- if(!is_numeric($akey)){
1214
- $data -> {$akey} = trim($aval);
1215
- }
1216
- }
1217
-
1218
- return $data;
1219
- }
1220
-
1221
- return false;
1222
- }
1223
-
1224
- function pre($sting_to_pre = '',$ob=false){
1225
-
1226
- if($sting_to_pre){
1227
-
1228
- if($ob){
1229
-
1230
- ob_start();
1231
- echo '<pre>';
1232
- print_r($sting_to_pre);
1233
- echo '</pre>';
1234
- $the_return = ob_get_contents();
1235
- ob_end_clean();
1236
- return $the_return;
1237
-
1238
- }else{
1239
- echo '<pre>';
1240
- print_r($sting_to_pre);
1241
- echo '</pre>';
1242
- }
1243
-
1244
- }
1245
- }
1246
-
1247
- function dbug($val,$prepend='',$prepend_color='red'){
1248
-
1249
- /*
1250
- $fp = fopen('E:\wwwusr\vhosts\tretinoin.dev.lamp2win.com\httpdocs\debug\log.txt', 'a');
1251
- fwrite($fp, '<span style="color:'.$prepend_color.';"><b>'.$prepend.'</b></span> '.$val."\n");
1252
- fclose($fp);
1253
- */
1254
- }
1255
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/.htaccess ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ Options -Indexes
2
+ Order deny,allow
3
+ Deny from all
inc/define.php CHANGED
@@ -1,6 +1,11 @@
1
  <?php
2
 
3
- define('W3TC_VERSION', '0.9.2.3');
 
 
 
 
 
4
  define('W3TC_POWERED_BY', 'W3 Total Cache/' . W3TC_VERSION);
5
  define('W3TC_EMAIL', 'w3tc@w3-edge.com');
6
  define('W3TC_PAYPAL_URL', 'https://www.paypal.com/cgi-bin/webscr');
@@ -16,6 +21,7 @@ define('W3TC_WIN', (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'));
16
 
17
  defined('W3TC_DIR') || define('W3TC_DIR', realpath(dirname(__FILE__) . '/..'));
18
  define('W3TC_FILE', 'w3-total-cache/w3-total-cache.php');
 
19
  define('W3TC_LIB_DIR', W3TC_DIR . '/lib');
20
  define('W3TC_LIB_W3_DIR', W3TC_LIB_DIR . '/W3');
21
  define('W3TC_LIB_MINIFY_DIR', W3TC_LIB_DIR . '/Minify');
@@ -24,7 +30,6 @@ define('W3TC_LIB_CSSTIDY_DIR', W3TC_LIB_DIR . '/CSSTidy');
24
  define('W3TC_LIB_MICROSOFT_DIR', W3TC_LIB_DIR . '/Microsoft');
25
  define('W3TC_LIB_NUSOAP_DIR', W3TC_LIB_DIR . '/Nusoap');
26
  define('W3TC_PLUGINS_DIR', W3TC_DIR . '/plugins');
27
- define('W3TC_DB_DIR', W3TC_DIR . '/db');
28
  define('W3TC_INSTALL_DIR', W3TC_DIR . '/wp-content');
29
  define('W3TC_INSTALL_MINIFY_DIR', W3TC_INSTALL_DIR . '/w3tc/min');
30
 
@@ -86,87 +91,12 @@ define('W3TC_ADDIN_FILE_ADVANCED_CACHE', WP_CONTENT_DIR . '/advanced-cache.php')
86
  define('W3TC_ADDIN_FILE_DB', WP_CONTENT_DIR . '/db.php');
87
  define('W3TC_ADDIN_FILE_OBJECT_CACHE', WP_CONTENT_DIR . '/object-cache.php');
88
 
89
- require_once W3TC_DIR . '/inc/compat.php';
90
- require_once W3TC_DIR . '/inc/plugin.php';
91
 
92
  @ini_set('pcre.backtrack_limit', 4194304);
93
  @ini_set('pcre.recursion_limit', 4194304);
94
 
95
- /**
96
- * Deactivate plugin after activation error
97
- *
98
- * @return void
99
- */
100
- function w3_activation_cleanup() {
101
- $active_plugins = (array) get_option('active_plugins');
102
- $active_plugins_network = (array) get_site_option('active_sitewide_plugins');
103
-
104
- // workaround for WPMU deactivation bug
105
- remove_action('deactivate_' . W3TC_FILE, 'deactivate_sitewide_plugin');
106
-
107
- do_action('deactivate_plugin', W3TC_FILE);
108
-
109
- $key = array_search(W3TC_FILE, $active_plugins);
110
-
111
- if ($key !== false) {
112
- array_splice($active_plugins, $key, 1);
113
- }
114
-
115
- unset($active_plugins_network[W3TC_FILE]);
116
-
117
- do_action('deactivate_' . W3TC_FILE);
118
- do_action('deactivated_plugin', W3TC_FILE);
119
-
120
- update_option('active_plugins', $active_plugins);
121
- update_site_option('active_sitewide_plugins', $active_plugins_network);
122
- }
123
-
124
- /**
125
- * W3 activate error
126
- *
127
- * @param string $error
128
- * @return void
129
- */
130
- function w3_activate_error($error)