PluginProbe
E2Pdf – Export Pdf Tool for WordPress / 1.32.15
E2Pdf – Export Pdf Tool for WordPress v1.32.15
1.32.49 1.32.48 1.32.43 1.32.40 1.32.34 1.32.32 1.32.31 1.32.26 1.32.22 1.32.23 1.32.18 1.32.17 1.32.15 trunk 1.00.00 1.00.13 1.01.01 1.02.02 1.03.07 1.04.07 1.05.03 1.06.02 1.07.11 1.08.00 1.08.06 All 72 releases
e2pdf / classes / helper / e2pdf-db.php

e2pdf-db.php in E2Pdf – Export Pdf Tool for WordPress 1.32.15, at classes/helper/e2pdf-db.php

927 lines 42.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * E2pdf Get Helper
5 *
6 * @copyright Copyright 2017 https://e2pdf.com
7 * @license GPLv3
8 * @version 1
9 * @link https://e2pdf.com
10 * @since 0.00.01
11 */
12 if (!defined('ABSPATH')) {
13 die('Access denied.');
14 }
15
16 class Helper_E2pdf_Db {
17
18 /**
19 * Prepare WHERE for sql requests
20 *
21 * @param string $condition - Array of conditions
22 *
23 * @return array - Filtered WHERE request
24 */
25 public function prepare_where($condition = array(), $sub_query = false) {
26
27 $sql = array();
28 $filter = array();
29 if (!$sub_query) {
30 $sql[] = " WHERE '1' = '1'";
31 }
32 $condition = apply_filters('e2pdf_helper_db_prepare_where_condition', $condition);
33
34 if (!empty($condition)) {
35 foreach ($condition as $key => $value) {
36
37 $sql_keys = explode('.', $key);
38 foreach ($sql_keys as $sql_sub_key => $sql_key) {
39 $sql_keys[$sql_sub_key] = '`' . $sql_key . '`';
40 }
41
42 if (is_array($value['value'])) {
43 foreach ($value['value'] as $sub_value) {
44 $sql[] = " " . implode('.', $sql_keys) . " {$value['condition']} '{$value['type']}'";
45 $filter[] = $sub_value;
46 }
47 } else {
48 if (!empty($value['or'])) {
49 $sub_sql = array();
50 $sub_sql[] = " " . implode('.', $sql_keys) . " {$value['condition']} '{$value['type']}'";
51 $filter[] = $value['value'];
52 foreach ($value['or'] as $or) {
53 $sub_where = $this->prepare_where($or, true);
54 $sub_sql[] = $sub_where['sql'];
55 foreach ($sub_where['filter'] as $sub_filter) {
56 $filter[] = $sub_filter;
57 }
58 }
59
60 $sql[] = ' (' . implode(' OR ', $sub_sql) . ')';
61 } else {
62 $sql[] = " " . implode('.', $sql_keys) . " {$value['condition']} '{$value['type']}'";
63 $filter[] = $value['value'];
64 }
65 }
66 }
67 }
68
69 $where = array(
70 'sql' => implode(' AND', $sql),
71 'filter' => $filter
72 );
73
74 return apply_filters('e2pdf_helper_db_prepare_where', $where, $condition);
75 }
76
77 /**
78 * Prepare ORDER_BY for sql requests
79 *
80 * @param string $condition - Array of conditions
81 *
82 * @return array - Filtered ORDER_BY request
83 */
84 public function prepare_orderby($condition = array()) {
85
86 $orderby = '';
87 $condition = apply_filters('e2pdf_helper_db_prepare_orderby_condition', $condition);
88
89 if (isset($condition['orderby']) && isset($condition['order'])) {
90 $orderby .= " ORDER BY {$condition['orderby']} {$condition['order']}";
91 }
92
93 return apply_filters('e2pdf_helper_db_prepare_orderby', $orderby, $condition);
94 }
95
96 public function prepare_limit($condition = array()) {
97
98 $limit = '';
99 $condition = apply_filters('e2pdf_helper_db_prepare_limit_condition', $condition);
100
101 if (isset($condition['limit']) && isset($condition['offset'])) {
102 $limit .= " LIMIT {$condition['offset']}, {$condition['limit']}";
103 }
104
105 return apply_filters('e2pdf_helper_db_prepare_limit', $limit, $condition);
106 }
107
108 public function db_init($db_prefix, $maybe_row_format = true) {
109 global $wpdb;
110
111 $collate = $this->db_collate();
112 if ($this->db_test_row_format($db_prefix)) {
113 $collate .= ' ROW_FORMAT=DYNAMIC';
114 }
115
116 $srpk = $wpdb->get_row("SHOW VARIABLES LIKE 'sql_require_primary_key'", ARRAY_A);
117 if ($srpk && isset($srpk['Value']) && $srpk['Value'] == 'ON') {
118 $wpdb->query('SET SESSION sql_require_primary_key = 0;');
119 }
120
121 $wpdb->query("CREATE TABLE IF NOT EXISTS `" . $db_prefix . "e2pdf_templates` (
122 `ID` int(11) NOT NULL AUTO_INCREMENT,
123 `uid` varchar(255) NOT NULL,
124 `pdf` text,
125 `title` text,
126 `created_at` datetime NOT NULL,
127 `updated_at` datetime NOT NULL,
128 `flatten` enum('0','1','2') NOT NULL DEFAULT '0',
129 `tab_order` enum('0','1','2','3') NOT NULL DEFAULT '0',
130 `compression` int(1) NOT NULL DEFAULT '-1',
131 `optimization` int(1) NOT NULL DEFAULT '-1',
132 `appearance` enum('0','1') NOT NULL DEFAULT '0',
133 `width` int(11) NOT NULL DEFAULT '0',
134 `height` int(11) NOT NULL DEFAULT '0',
135 `extension` varchar(255) NOT NULL,
136 `item` varchar(255) NOT NULL,
137 `item1` varchar(255) NOT NULL,
138 `item2` varchar(255) NOT NULL,
139 `format` varchar(255) NOT NULL DEFAULT 'pdf',
140 `resample` varchar(255) NOT NULL DEFAULT '100',
141 `dataset_title` text NOT NULL,
142 `dataset_title1` text NOT NULL,
143 `dataset_title2` text NOT NULL,
144 `button_title` text NOT NULL,
145 `dpdf` text NOT NULL,
146 `inline` enum('0','1') NOT NULL DEFAULT '0',
147 `auto` enum('0','1') NOT NULL DEFAULT '0',
148 `rtl` enum('0','1') NOT NULL DEFAULT '0',
149 `font_processor` enum('0','1') NOT NULL DEFAULT '0',
150 `name` text NOT NULL,
151 `savename` text NOT NULL,
152 `password` text NOT NULL,
153 `owner_password` text NOT NULL,
154 `permissions` longtext NOT NULL,
155 `hooks` longtext NOT NULL,
156 `meta_title` text NOT NULL,
157 `meta_subject` text NOT NULL,
158 `meta_author` text NOT NULL,
159 `meta_keywords` text NOT NULL,
160 `lang_code` varchar(255) NOT NULL,
161 `font` varchar(255) NOT NULL,
162 `font_size` varchar(255) NOT NULL,
163 `font_color` varchar(255) NOT NULL,
164 `line_height` varchar(255) NOT NULL,
165 `text_align` varchar(255) NOT NULL,
166 `fonts` longtext NOT NULL,
167 `trash` enum('0','1') NOT NULL DEFAULT '0',
168 `activated` enum('0','1') NOT NULL DEFAULT '0',
169 `locked` enum('0','1') NOT NULL DEFAULT '0',
170 `author` int(11) NOT NULL,
171 `properties` longtext NOT NULL,
172 `actions` longtext NOT NULL,
173 PRIMARY KEY (`ID`)
174 ) " . $collate . "");
175
176 if ($wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'blank';")) {
177 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` DROP COLUMN `blank`;");
178 }
179
180 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'meta_title';")) {
181 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `meta_title` text NOT NULL AFTER password;");
182 }
183
184 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'meta_subject';")) {
185 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `meta_subject` text NOT NULL AFTER meta_title;");
186 }
187
188 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'meta_author';")) {
189 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `meta_author` text NOT NULL AFTER meta_subject;");
190 }
191
192 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'meta_keywords';")) {
193 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `meta_keywords` text NOT NULL AFTER meta_author;");
194 }
195
196 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'lang_code';")) {
197 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `lang_code` text NOT NULL AFTER meta_keywords;");
198 }
199
200 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'actions';")) {
201 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `actions` longtext NOT NULL AFTER author;");
202 }
203
204 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'properties';")) {
205 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `properties` longtext NOT NULL AFTER author;");
206 }
207
208 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'rtl';")) {
209 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `rtl` enum('0','1') NOT NULL DEFAULT '0' AFTER auto;");
210 }
211
212 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'font_processor';")) {
213 if (get_option('e2pdf_font_processor', '0') == '1') {
214 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `font_processor` enum('0','1') NOT NULL DEFAULT '1' AFTER rtl;");
215 } else {
216 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `font_processor` enum('0','1') NOT NULL DEFAULT '0' AFTER rtl;");
217 }
218 }
219
220 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'text_align';")) {
221 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `text_align` varchar(255) NOT NULL AFTER line_height;");
222 }
223
224 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'tab_order';")) {
225 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `tab_order` enum('0','1','2','3') NOT NULL DEFAULT '0' AFTER flatten;");
226 }
227
228 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'item1';")) {
229 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `item1` varchar(255) NOT NULL AFTER item;");
230 }
231
232 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'item2';")) {
233 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `item2` varchar(255) NOT NULL AFTER item1;");
234 }
235
236 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'dataset_title1';")) {
237 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `dataset_title1` text NOT NULL AFTER dataset_title;");
238 }
239
240 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'dataset_title2';")) {
241 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `dataset_title2` text NOT NULL AFTER dataset_title1;");
242 }
243
244 if ($wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` WHERE Field = 'format' and Type LIKE '%enum%';")) {
245 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` DROP COLUMN `format`;");
246 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `format` varchar(255) NOT NULL DEFAULT 'pdf' AFTER item2;");
247 }
248
249 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'resample';")) {
250 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `resample` varchar(255) NOT NULL DEFAULT '100' AFTER format;");
251 }
252
253 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'owner_password';")) {
254 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `owner_password` text NOT NULL AFTER password;");
255 }
256
257 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'permissions';")) {
258 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `permissions` longtext NOT NULL AFTER owner_password;");
259 }
260
261 $wpdb->query("UPDATE `" . $db_prefix . "e2pdf_templates` SET permissions = 'a:1:{i:0;s:8:\"printing\";}' WHERE permissions = ''");
262
263 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'hooks';")) {
264 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `hooks` longtext NOT NULL AFTER permissions;");
265 }
266
267 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'dpdf';")) {
268 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `dpdf` text NOT NULL AFTER button_title;");
269 }
270
271 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'savename';")) {
272 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `savename` text NOT NULL AFTER name;");
273 }
274
275 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'optimization';")) {
276 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `optimization` int(1) NOT NULL DEFAULT '-1' AFTER compression;");
277 }
278
279 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_templates` LIKE 'attachments';")) {
280 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_templates` ADD COLUMN `attachments` longtext NOT NULL AFTER fonts;");
281 }
282
283 $wpdb->query("CREATE TABLE IF NOT EXISTS `" . $db_prefix . "e2pdf_entries` (
284 `ID` bigint(20) NOT NULL AUTO_INCREMENT,
285 `uid` varchar(255) NOT NULL,
286 `entry` longtext,
287 `pdf_num` int(11) NOT NULL DEFAULT '0',
288 PRIMARY KEY (`ID`)
289 ) " . $collate . "");
290
291 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_entries` LIKE 'pdf_num';")) {
292 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_entries` ADD COLUMN `pdf_num` int(11) NOT NULL DEFAULT '0';");
293 }
294
295 $index = $wpdb->get_row("SHOW INDEX FROM `" . $db_prefix . "e2pdf_entries` WHERE key_name = 'uid';");
296 if (is_null($index)) {
297 $wpdb->query("CREATE INDEX `uid` ON `" . $db_prefix . "e2pdf_entries` (`uid`);");
298 }
299
300 if ($wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_entries` WHERE Field = 'ID' and Type LIKE 'int(11)';")) {
301 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_entries` CHANGE `ID` `ID` bigint(20) NOT NULL AUTO_INCREMENT;");
302 }
303
304 $wpdb->query("CREATE TABLE IF NOT EXISTS `" . $db_prefix . "e2pdf_datasets` (
305 `ID` bigint(20) NOT NULL AUTO_INCREMENT,
306 `extension` varchar(255) NOT NULL,
307 `item` varchar(255) NOT NULL,
308 `entry` longtext,
309 `created_at` datetime NOT NULL,
310 PRIMARY KEY (`ID`)
311 ) " . $collate . "");
312
313 if ($wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_datasets` WHERE Field = 'ID' and Type LIKE 'int(11)';")) {
314 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_datasets` CHANGE `ID` `ID` bigint(20) NOT NULL AUTO_INCREMENT;");
315 }
316
317 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_datasets` LIKE 'created_at';")) {
318 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_datasets` ADD COLUMN `created_at` datetime NOT NULL AFTER entry;");
319 }
320
321 $wpdb->query("CREATE TABLE IF NOT EXISTS `" . $db_prefix . "e2pdf_pages` (
322 `PID` bigint(20) NOT NULL AUTO_INCREMENT,
323 `page_id` int(11) NOT NULL DEFAULT '0',
324 `template_id` int(11) NOT NULL DEFAULT '0',
325 `properties` longtext NOT NULL,
326 `actions` longtext NOT NULL,
327 `revision_id` int(11) NOT NULL DEFAULT '0',
328 PRIMARY KEY (`PID`)
329 ) " . $collate . "");
330
331 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_pages` LIKE 'actions';")) {
332 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_pages` ADD COLUMN `actions` longtext NOT NULL;");
333 }
334
335 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_pages` LIKE 'revision_id';")) {
336 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_pages` ADD COLUMN `revision_id` int(11) NOT NULL DEFAULT '0' AFTER actions;");
337 }
338
339 $index = $wpdb->get_row("SHOW INDEX FROM `" . $db_prefix . "e2pdf_pages` WHERE key_name = 'page_id';");
340 if (is_null($index)) {
341 $wpdb->query("CREATE INDEX `page_id` ON `" . $db_prefix . "e2pdf_pages` (`page_id`);");
342 }
343
344 $index = $wpdb->get_row("SHOW INDEX FROM `" . $db_prefix . "e2pdf_pages` WHERE key_name = 'template_id';");
345 if (is_null($index)) {
346 $wpdb->query("CREATE INDEX `template_id` ON `" . $db_prefix . "e2pdf_pages` (`template_id`);");
347 }
348
349 $index = $wpdb->get_row("SHOW INDEX FROM `" . $db_prefix . "e2pdf_pages` WHERE key_name = 'revision_id';");
350 if (is_null($index)) {
351 $wpdb->query("CREATE INDEX `revision_id` ON `" . $db_prefix . "e2pdf_pages` (`revision_id`);");
352 }
353
354 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_pages` LIKE 'PID';")) {
355 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_pages` ADD COLUMN `PID` bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;");
356 }
357
358 $wpdb->query("CREATE TABLE IF NOT EXISTS `" . $db_prefix . "e2pdf_elements` (
359 `PID` bigint(20) NOT NULL AUTO_INCREMENT,
360 `page_id` int(11) NOT NULL DEFAULT '0',
361 `template_id` int(11) NOT NULL DEFAULT '0',
362 `element_id` int(11) NOT NULL DEFAULT '0',
363 `name` text NOT NULL,
364 `type` varchar(255) NOT NULL,
365 `top` int(11) NOT NULL DEFAULT '0',
366 `left` int(11) NOT NULL DEFAULT '0',
367 `width` int(11) NOT NULL DEFAULT '0',
368 `height` int(11) NOT NULL DEFAULT '0',
369 `value` longtext NOT NULL,
370 `properties` longtext NOT NULL,
371 `actions` longtext NOT NULL,
372 `revision_id` int(11) NOT NULL DEFAULT '0',
373 PRIMARY KEY (`PID`)
374 ) " . $collate . "");
375
376 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_elements` LIKE 'actions';")) {
377 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_elements` ADD COLUMN `actions` longtext NOT NULL;");
378 }
379
380 if ($wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_pages` LIKE 'ID';") && $wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_elements` LIKE 'ID';")) {
381 $wpdb->query("UPDATE `" . $db_prefix . "e2pdf_elements` ee INNER JOIN `" . $db_prefix . "e2pdf_pages` ep ON ee.page_id = ep.ID set ee.page_id = ep.page_id;");
382 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_pages` DROP COLUMN `ID`;");
383 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_elements` DROP COLUMN `ID`;");
384 }
385
386 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_elements` LIKE 'name';")) {
387 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_elements` ADD COLUMN `name` text NOT NULL AFTER element_id;");
388 }
389
390 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_elements` LIKE 'revision_id';")) {
391 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_elements` ADD COLUMN `revision_id` int(11) NOT NULL DEFAULT '0' AFTER actions;");
392 }
393
394 $index = $wpdb->get_row("SHOW INDEX FROM `" . $db_prefix . "e2pdf_elements` WHERE key_name = 'page_id';");
395 if (is_null($index)) {
396 $wpdb->query("CREATE INDEX `page_id` ON `" . $db_prefix . "e2pdf_elements` (`page_id`);");
397 }
398
399 $index = $wpdb->get_row("SHOW INDEX FROM `" . $db_prefix . "e2pdf_elements` WHERE key_name = 'template_id'");
400 if (is_null($index)) {
401 $wpdb->query("CREATE INDEX `template_id` ON `" . $db_prefix . "e2pdf_elements` (`template_id`); ");
402 }
403
404 $index = $wpdb->get_row("SHOW INDEX FROM `" . $db_prefix . "e2pdf_elements` WHERE key_name = 'revision_id'");
405 if (is_null($index)) {
406 $wpdb->query("CREATE INDEX `revision_id` ON `" . $db_prefix . "e2pdf_elements` (`revision_id`); ");
407 }
408
409 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_elements` LIKE 'PID';")) {
410 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_elements` ADD COLUMN `PID` bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;");
411 }
412
413 $wpdb->query("CREATE TABLE IF NOT EXISTS `" . $db_prefix . "e2pdf_revisions` (
414 `PID` bigint(20) NOT NULL AUTO_INCREMENT,
415 `revision_id` int(11) NOT NULL DEFAULT '0',
416 `template_id` int(11) NOT NULL DEFAULT '0',
417 `pdf` text,
418 `title` text,
419 `created_at` datetime NOT NULL,
420 `updated_at` datetime NOT NULL,
421 `flatten` enum('0','1','2') NOT NULL DEFAULT '0',
422 `tab_order` enum('0','1','2','3') NOT NULL DEFAULT '0',
423 `compression` int(1) NOT NULL DEFAULT '-1',
424 `optimization` int(1) NOT NULL DEFAULT '-1',
425 `appearance` enum('0','1') NOT NULL DEFAULT '0',
426 `width` int(11) NOT NULL DEFAULT '0',
427 `height` int(11) NOT NULL DEFAULT '0',
428 `extension` varchar(255) NOT NULL,
429 `item` varchar(255) NOT NULL,
430 `item1` varchar(255) NOT NULL,
431 `item2` varchar(255) NOT NULL,
432 `format` varchar(255) NOT NULL DEFAULT 'pdf',
433 `resample` varchar(255) NOT NULL DEFAULT '100',
434 `dataset_title` text NOT NULL,
435 `dataset_title1` text NOT NULL,
436 `dataset_title2` text NOT NULL,
437 `button_title` text NOT NULL,
438 `dpdf` text NOT NULL,
439 `inline` enum('0','1') NOT NULL DEFAULT '0',
440 `auto` enum('0','1') NOT NULL DEFAULT '0',
441 `rtl` enum('0','1') NOT NULL DEFAULT '0',
442 `font_processor` enum('0','1') NOT NULL DEFAULT '0',
443 `name` text NOT NULL,
444 `savename` text NOT NULL,
445 `password` text NOT NULL,
446 `owner_password` text NOT NULL,
447 `permissions` longtext NOT NULL,
448 `hooks` longtext NOT NULL,
449 `meta_title` text NOT NULL,
450 `meta_subject` text NOT NULL,
451 `meta_author` text NOT NULL,
452 `meta_keywords` text NOT NULL,
453 `lang_code` varchar(255) NOT NULL,
454 `font` varchar(255) NOT NULL,
455 `font_size` varchar(255) NOT NULL,
456 `font_color` varchar(255) NOT NULL,
457 `line_height` varchar(255) NOT NULL,
458 `text_align` varchar(255) NOT NULL,
459 `fonts` longtext NOT NULL,
460 `author` int(11) NOT NULL,
461 `properties` longtext NOT NULL,
462 `actions` longtext NOT NULL,
463 PRIMARY KEY (`PID`)
464 ) " . $collate . "");
465
466 $index = $wpdb->get_row("SHOW INDEX FROM `" . $db_prefix . "e2pdf_revisions` WHERE key_name = 'revision_id';");
467 if (is_null($index)) {
468 $wpdb->query("CREATE INDEX `revision_id` ON `" . $db_prefix . "e2pdf_revisions` (`revision_id`);");
469 }
470
471 $index = $wpdb->get_row("SHOW INDEX FROM `" . $db_prefix . "e2pdf_revisions` WHERE key_name = 'template_id';");
472 if (is_null($index)) {
473 $wpdb->query("CREATE INDEX `template_id` ON `" . $db_prefix . "e2pdf_revisions` (`template_id`);");
474 }
475
476 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_revisions` LIKE 'lang_code';")) {
477 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `lang_code` text NOT NULL AFTER meta_keywords;");
478 }
479
480 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_revisions` LIKE 'actions';")) {
481 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `actions` longtext NOT NULL AFTER author;");
482 }
483
484 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_revisions` LIKE 'properties';")) {
485 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `properties` longtext NOT NULL AFTER author;");
486 }
487
488 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_revisions` LIKE 'rtl';")) {
489 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `rtl` enum('0','1') NOT NULL DEFAULT '0' AFTER auto;");
490 }
491
492 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_revisions` LIKE 'font_processor';")) {
493 if (get_option('e2pdf_font_processor', '0') == '1') {
494 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `font_processor` enum('0','1') NOT NULL DEFAULT '1' AFTER rtl;");
495 } else {
496 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `font_processor` enum('0','1') NOT NULL DEFAULT '0' AFTER rtl;");
497 }
498 }
499
500 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_revisions` LIKE 'text_align';")) {
501 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `text_align` varchar(255) NOT NULL AFTER line_height;");
502 }
503
504 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_revisions` LIKE 'tab_order';")) {
505 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `tab_order` enum('0','1','2','3') NOT NULL DEFAULT '0' AFTER flatten;");
506 }
507
508 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_revisions` LIKE 'item1';")) {
509 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `item1` varchar(255) NOT NULL AFTER item;");
510 }
511
512 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_revisions` LIKE 'item2';")) {
513 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `item2` varchar(255) NOT NULL AFTER item1;");
514 }
515
516 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_revisions` LIKE 'dataset_title1';")) {
517 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `dataset_title1` text NOT NULL AFTER dataset_title;");
518 }
519
520 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_revisions` LIKE 'dataset_title2';")) {
521 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `dataset_title2` text NOT NULL AFTER dataset_title1;");
522 }
523
524 if ($wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_revisions` WHERE Field = 'format' and Type LIKE '%enum%';")) {
525 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` DROP COLUMN `format`;");
526 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `format` varchar(255) NOT NULL DEFAULT 'pdf' AFTER item2;");
527 }
528
529 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_revisions` LIKE 'resample';")) {
530 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `resample` varchar(255) NOT NULL DEFAULT '100' AFTER format;");
531 }
532
533 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_revisions` LIKE 'owner_password';")) {
534 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `owner_password` text NOT NULL AFTER password;");
535 }
536
537 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_revisions` LIKE 'permissions';")) {
538 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `permissions` longtext NOT NULL AFTER owner_password;");
539 }
540
541 $wpdb->query("UPDATE `" . $db_prefix . "e2pdf_revisions` SET permissions = 'a:1:{i:0;s:8:\"printing\";}' WHERE permissions = ''");
542
543 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_revisions` LIKE 'hooks';")) {
544 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `hooks` longtext NOT NULL AFTER permissions;");
545 }
546
547 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_revisions` LIKE 'dpdf';")) {
548 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `dpdf` text NOT NULL AFTER button_title;");
549 }
550
551 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_revisions` LIKE 'savename';")) {
552 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `savename` text NOT NULL AFTER name;");
553 }
554
555 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_revisions` LIKE 'PID';")) {
556 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `PID` bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;");
557 }
558
559 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_revisions` LIKE 'optimization';")) {
560 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `optimization` int(1) NOT NULL DEFAULT '-1' AFTER compression;");
561 }
562
563 if (!$wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_revisions` LIKE 'attachments';")) {
564 $wpdb->query("ALTER TABLE `" . $db_prefix . "e2pdf_revisions` ADD COLUMN `attachments` longtext NOT NULL AFTER fonts;");
565 }
566
567 $wpdb->query("CREATE TABLE IF NOT EXISTS `" . $db_prefix . "e2pdf_bulks` (
568 `ID` int(11) NOT NULL AUTO_INCREMENT,
569 `uid` varchar(255) NOT NULL,
570 `template_id` int(11) NOT NULL DEFAULT '0',
571 `count` int(11) NOT NULL DEFAULT '0',
572 `total` int(11) NOT NULL DEFAULT '0',
573 `dataset` longtext NOT NULL,
574 `datasets` longtext NOT NULL,
575 `options` longtext NOT NULL,
576 `status` varchar(255) NOT NULL DEFAULT 'pending',
577 `created_at` datetime NOT NULL,
578 PRIMARY KEY (`ID`)
579 ) " . $collate . "");
580
581 if (!$this->db_check($db_prefix) && $maybe_row_format) {
582 $this->db_row_format($db_prefix);
583 } else {
584 $this->db_optimize($db_prefix);
585 update_option('e2pdf_font_processor', '1');
586 }
587
588 return true;
589 }
590
591 public function db_test_row_format($db_prefix) {
592 global $wpdb;
593
594 $collate = $this->db_collate() . ' ROW_FORMAT=DYNAMIC';
595
596 $wpdb->query("CREATE TABLE IF NOT EXISTS `" . $db_prefix . "e2pdf_test_db` (
597 `ID` int(11) NOT NULL AUTO_INCREMENT,
598 PRIMARY KEY (`ID`)
599 ) " . $collate . "");
600
601 $pass = $wpdb->get_var("SHOW COLUMNS FROM `" . $db_prefix . "e2pdf_test_db` LIKE 'ID';");
602 $wpdb->query("DROP TABLE IF EXISTS `" . $db_prefix . "e2pdf_test_db`;");
603
604 if ($pass) {
605 return true;
606 } else {
607 return false;
608 }
609 }
610
611 public function db_row_format($db_prefix) {
612 global $wpdb;
613 if ($this->db_test_row_format($db_prefix)) {
614 $db_structure = $this->db_structure($db_prefix);
615 foreach ($db_structure as $table => $columns) {
616 $wpdb->query('ALTER TABLE `' . $db_prefix . $table . '` ROW_FORMAT=DYNAMIC;');
617 $wpdb->query('OPTIMIZE TABLE `' . $db_prefix . $table . '`;');
618 }
619 $this->db_init($db_prefix, false);
620 }
621 return true;
622 }
623
624 public function db_optimize($db_prefix) {
625 global $wpdb;
626 $db_structure = $this->db_structure($db_prefix);
627 foreach ($db_structure as $table => $columns) {
628 $wpdb->query("OPTIMIZE TABLE `" . $db_prefix . $table . "`;");
629 }
630 return true;
631 }
632
633 public function db_repair($db_prefix) {
634 global $wpdb;
635 $db_structure = $this->db_structure($db_prefix);
636 foreach ($db_structure as $table => $columns) {
637 $wpdb->query("REPAIR TABLE `" . $db_prefix . $table . "`;");
638 }
639 return true;
640 }
641
642 public function db_repair_collate($db_prefix) {
643 global $wpdb;
644
645 $db_structure = $this->db_structure($db_prefix);
646
647 $collate = '';
648 if (!empty($wpdb->charset)) {
649 $collate = 'CONVERT TO CHARACTER SET ' . $wpdb->charset;
650 }
651 if (!empty($wpdb->collate)) {
652 $collate .= ' COLLATE ' . $wpdb->collate;
653 }
654
655 if (!empty($collate)) {
656 foreach ($db_structure as $table => $columns) {
657 $wpdb->query('ALTER TABLE `' . $db_prefix . $table . '` ' . $collate . ';');
658 $wpdb->query('OPTIMIZE TABLE `' . $db_prefix . $table . '`;');
659 }
660 $this->db_init($db_prefix, false);
661 }
662 }
663
664 public function db_collate() {
665 global $wpdb;
666 return $wpdb->has_cap('collation') ? $wpdb->get_charset_collate() : 'CHARSET=utf8 COLLATE=utf8_general_ci';
667 }
668
669 public function db_check($db_prefix) {
670 $db_structure = $this->db_structure($db_prefix, true);
671 foreach ($db_structure as $table) {
672 foreach ($table['columns'] as $column) {
673 if (!isset($column['check']) || (isset($column['check']) && !$column['check'])) {
674 return false;
675 }
676 }
677 }
678 return true;
679 }
680
681 public function db_check_collate($db_prefix) {
682 global $wpdb;
683 $db_structure = $this->db_structure($db_prefix);
684 if (!empty($wpdb->collate)) {
685 foreach ($db_structure as $table => $columns) {
686 $condition = array(
687 'TABLE_SCHEMA' => array(
688 'condition' => '=',
689 'value' => DB_NAME,
690 'type' => '%s'
691 ),
692 'TABLE_NAME' => array(
693 'condition' => '=',
694 'value' => $db_prefix . $table,
695 'type' => '%s'
696 ),
697 'TABLE_COLLATION' => array(
698 'condition' => '=',
699 'value' => $wpdb->collate,
700 'type' => '%s'
701 ),
702 );
703 $where = $this->prepare_where($condition);
704 $check = $wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM `INFORMATION_SCHEMA`.`TABLES` ' . $where['sql'] . '', $where['filter']));
705 if (!$check) {
706 return false;
707 }
708 }
709 }
710 return true;
711 }
712
713 public function db_structure($db_prefix, $check = false) {
714 global $wpdb;
715
716 $db_structure = array(
717 'e2pdf_templates' => array(
718 'format' => __('Undefined', 'e2pdf'),
719 'check' => false,
720 'columns' => array(
721 'ID' => array(),
722 'uid' => array(),
723 'pdf' => array(),
724 'title' => array(),
725 'created_at' => array(),
726 'updated_at' => array(),
727 'flatten' => array(),
728 'tab_order' => array(),
729 'compression' => array(),
730 'optimization' => array(),
731 'appearance' => array(),
732 'width' => array(),
733 'height' => array(),
734 'extension' => array(),
735 'item' => array(),
736 'item1' => array(),
737 'item2' => array(),
738 'format' => array(),
739 'resample' => array(),
740 'dataset_title' => array(),
741 'dataset_title1' => array(),
742 'dataset_title2' => array(),
743 'button_title' => array(),
744 'dpdf' => array(),
745 'inline' => array(),
746 'auto' => array(),
747 'rtl' => array(),
748 'font_processor' => array(),
749 'name' => array(),
750 'savename' => array(),
751 'password' => array(),
752 'owner_password' => array(),
753 'permissions' => array(),
754 'hooks' => array(),
755 'meta_title' => array(),
756 'meta_subject' => array(),
757 'meta_author' => array(),
758 'meta_keywords' => array(),
759 'lang_code' => array(),
760 'font' => array(),
761 'font_size' => array(),
762 'font_color' => array(),
763 'line_height' => array(),
764 'text_align' => array(),
765 'fonts' => array(),
766 'attachments' => array(),
767 'trash' => array(),
768 'activated' => array(),
769 'locked' => array(),
770 'author' => array(),
771 'properties' => array(),
772 'actions' => array(),
773 )
774 ),
775 'e2pdf_entries' => array(
776 'format' => __('Undefined', 'e2pdf'),
777 'check' => false,
778 'columns' => array(
779 'ID' => array(),
780 'uid' => array(),
781 'entry' => array(),
782 'pdf_num' => array(),
783 )
784 ),
785 'e2pdf_datasets' => array(
786 'format' => '',
787 'check' => false,
788 'columns' => array(
789 'ID' => array(),
790 'extension' => array(),
791 'item' => array(),
792 'entry' => array(),
793 'created_at' => array(),
794 )
795 ),
796 'e2pdf_pages' => array(
797 'format' => __('Undefined', 'e2pdf'),
798 'check' => false,
799 'columns' => array(
800 'PID' => array(),
801 'page_id' => array(),
802 'template_id' => array(),
803 'properties' => array(),
804 'actions' => array(),
805 'revision_id' => array(),
806 )
807 ),
808 'e2pdf_elements' => array(
809 'format' => __('Undefined', 'e2pdf'),
810 'check' => false,
811 'columns' => array(
812 'PID' => array(),
813 'page_id' => array(),
814 'template_id' => array(),
815 'element_id' => array(),
816 'name' => array(),
817 'type' => array(),
818 'top' => array(),
819 'left' => array(),
820 'width' => array(),
821 'height' => array(),
822 'value' => array(),
823 'properties' => array(),
824 'actions' => array(),
825 'revision_id' => array(),
826 )
827 ),
828 'e2pdf_revisions' => array(
829 'format' => __('Undefined', 'e2pdf'),
830 'check' => false,
831 'columns' => array(
832 'PID' => array(),
833 'revision_id' => array(),
834 'template_id' => array(),
835 'pdf' => array(),
836 'title' => array(),
837 'created_at' => array(),
838 'updated_at' => array(),
839 'flatten' => array(),
840 'tab_order' => array(),
841 'compression' => array(),
842 'optimization' => array(),
843 'appearance' => array(),
844 'width' => array(),
845 'height' => array(),
846 'extension' => array(),
847 'item' => array(),
848 'item1' => array(),
849 'item2' => array(),
850 'format' => array(),
851 'resample' => array(),
852 'dataset_title' => array(),
853 'dataset_title1' => array(),
854 'dataset_title2' => array(),
855 'button_title' => array(),
856 'dpdf' => array(),
857 'inline' => array(),
858 'auto' => array(),
859 'rtl' => array(),
860 'font_processor' => array(),
861 'name' => array(),
862 'savename' => array(),
863 'password' => array(),
864 'owner_password' => array(),
865 'permissions' => array(),
866 'hooks' => array(),
867 'meta_title' => array(),
868 'meta_subject' => array(),
869 'meta_author' => array(),
870 'meta_keywords' => array(),
871 'lang_code' => array(),
872 'font' => array(),
873 'font_size' => array(),
874 'font_color' => array(),
875 'line_height' => array(),
876 'text_align' => array(),
877 'fonts' => array(),
878 'attachments' => array(),
879 'author' => array(),
880 'properties' => array(),
881 'actions' => array(),
882 )
883 )
884 );
885
886 if ($check) {
887 foreach ($db_structure as $table_key => $table) {
888 $condition = array(
889 'TABLE_SCHEMA' => array(
890 'condition' => '=',
891 'value' => DB_NAME,
892 'type' => '%s'
893 ),
894 'TABLE_NAME' => array(
895 'condition' => '=',
896 'value' => $db_prefix . $table_key,
897 'type' => '%s'
898 ),
899 );
900 $where = $this->prepare_where($condition);
901 $table_exists = $wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM `INFORMATION_SCHEMA`.`TABLES` ' . $where['sql'] . '', $where['filter']));
902 if ($table_exists) {
903
904 $db_structure[$table_key]['check'] = true;
905 $table_columns = $wpdb->get_results($wpdb->prepare('SELECT `COLUMN_NAME` FROM `INFORMATION_SCHEMA`.`COLUMNS` ' . $where['sql'] . '', $where['filter']), ARRAY_A);
906 $table_data = $wpdb->get_row($wpdb->prepare('SELECT `ROW_FORMAT`, `TABLE_COLLATION` FROM `INFORMATION_SCHEMA`.`TABLES` ' . $where['sql'] . '', $where['filter']), ARRAY_A);
907
908 $db_structure[$table_key]['format'] = !empty($table_data['ROW_FORMAT']) ? $table_data['ROW_FORMAT'] : '';
909 $db_structure[$table_key]['collation'] = !empty($table_data['TABLE_COLLATION']) ? $table_data['TABLE_COLLATION'] : '';
910
911 foreach ($table_columns as $table_column) {
912 $table_column_name = isset($table_column['COLUMN_NAME']) ? $table_column['COLUMN_NAME'] : false;
913 if ($table_column_name) {
914 if (isset($table['columns'][$table_column_name])) {
915 $db_structure[$table_key]['columns'][$table_column_name]['check'] = true;
916 } else {
917 $db_structure[$table_key]['columns'][$table_column_name]['check'] = false;
918 }
919 }
920 }
921 }
922 }
923 }
924 return $db_structure;
925 }
926 }
927