PageRenderTime 44ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/broken-link-checker/includes/admin/db-schema.php

https://bitbucket.org/lgorence/quickpress
PHP | 97 lines | 75 code | 18 blank | 4 comment | 3 complexity | 4a953788864b02a43484304df6f954bb MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, AGPL-1.0
  1. <?php
  2. if( !function_exists('blc_get_db_schema') ){
  3. function blc_get_db_schema(){
  4. global $wpdb;
  5. //Use the character set and collation that's configured for WP tables
  6. $charset_collate = '';
  7. if ( !empty($wpdb->charset) ){
  8. //Some German installs use "utf-8" (invalid) instead of "utf8" (valid). None of
  9. //the charset ids supported by MySQL contain dashes, so we can safely strip them.
  10. //See http://dev.mysql.com/doc/refman/5.0/en/charset-charsets.html
  11. $charset = str_replace('-', '', $wpdb->charset);
  12. $charset_collate = "DEFAULT CHARACTER SET {$charset}";
  13. }
  14. if ( !empty($wpdb->collate) ){
  15. $charset_collate .= " COLLATE {$wpdb->collate}";
  16. }
  17. $blc_db_schema = <<<EOM
  18. CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}blc_filters` (
  19. `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  20. `name` varchar(100) NOT NULL,
  21. `params` text NOT NULL,
  22. PRIMARY KEY (`id`)
  23. ) {$charset_collate};
  24. CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}blc_instances` (
  25. `instance_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  26. `link_id` int(10) unsigned NOT NULL,
  27. `container_id` int(10) unsigned NOT NULL,
  28. `container_type` varchar(40) NOT NULL DEFAULT 'post',
  29. `link_text` varchar(250) NOT NULL DEFAULT '',
  30. `parser_type` varchar(40) NOT NULL DEFAULT 'link',
  31. `container_field` varchar(250) NOT NULL DEFAULT '',
  32. `link_context` varchar(250) NOT NULL DEFAULT '',
  33. `raw_url` text NOT NULL,
  34. PRIMARY KEY (`instance_id`),
  35. KEY `link_id` (`link_id`),
  36. KEY `source_id` (`container_type`, `container_id`),
  37. KEY `parser_type` (`parser_type`)
  38. ) {$charset_collate};
  39. CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}blc_links` (
  40. `link_id` int(20) unsigned NOT NULL AUTO_INCREMENT,
  41. `url` text CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
  42. `first_failure` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  43. `last_check` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  44. `last_success` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  45. `last_check_attempt` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  46. `check_count` int(4) unsigned NOT NULL DEFAULT '0',
  47. `final_url` text CHARACTER SET latin1 COLLATE latin1_general_cs NOT NULL,
  48. `redirect_count` smallint(5) unsigned NOT NULL DEFAULT '0',
  49. `log` text NOT NULL,
  50. `http_code` smallint(6) NOT NULL DEFAULT '0',
  51. `status_code` varchar(100) DEFAULT '',
  52. `status_text` varchar(250) DEFAULT '',
  53. `request_duration` float NOT NULL DEFAULT '0',
  54. `timeout` tinyint(1) unsigned NOT NULL DEFAULT '0',
  55. `broken` tinyint(1) NOT NULL DEFAULT '0',
  56. `may_recheck` tinyint(1) NOT NULL DEFAULT '1',
  57. `being_checked` tinyint(1) NOT NULL DEFAULT '0',
  58. `result_hash` varchar(200) NOT NULL DEFAULT '',
  59. `false_positive` tinyint(1) NOT NULL DEFAULT '0',
  60. `dismissed` tinyint(1) NOT NULL DEFAULT '0',
  61. PRIMARY KEY (`link_id`),
  62. KEY `url` (`url`(150)),
  63. KEY `final_url` (`final_url`(150)),
  64. KEY `http_code` (`http_code`),
  65. KEY `broken` (`broken`)
  66. ) {$charset_collate};
  67. CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}blc_synch` (
  68. `container_id` int(20) unsigned NOT NULL,
  69. `container_type` varchar(40) NOT NULL,
  70. `synched` tinyint(3) unsigned NOT NULL,
  71. `last_synch` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  72. PRIMARY KEY (`container_type`,`container_id`),
  73. KEY `synched` (`synched`)
  74. ) {$charset_collate};
  75. EOM;
  76. return $blc_db_schema;
  77. }
  78. }
  79. ?>