PageRenderTime 38ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/w3-total-cache/lib/W3/Cdn.php

https://bitbucket.org/openfarmtech/weblog-content
PHP | 91 lines | 61 code | 17 blank | 13 comment | 17 complexity | 58906b16256fc2da7282afb504d95188 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0, LGPL-2.0, LGPL-3.0, BSD-3-Clause, GPL-3.0, LGPL-2.1, AGPL-3.0, CC-BY-SA-3.0
  1. <?php
  2. /**
  3. * W3 CDN Class
  4. */
  5. if (!defined('W3_CDN_FTP')) {
  6. define('W3_CDN_FTP', 'ftp');
  7. }
  8. if (!defined('W3_CDN_CF')) {
  9. define('W3_CDN_CF', 'cf');
  10. }
  11. if (!defined('W3_CDN_S3')) {
  12. define('W3_CDN_S3', 's3');
  13. }
  14. if (!defined('W3_CDN_MIRROR')) {
  15. define('W3_CDN_MIRROR', 'mirror');
  16. }
  17. if (!defined('W3_CDN_NETDNA')) {
  18. define('W3_CDN_NETDNA', 'netdna');
  19. }
  20. if (!defined('W3_CDN_RSCF')) {
  21. define('W3_CDN_RSCF', 'rscf');
  22. }
  23. /**
  24. * Class W3_Cdn
  25. */
  26. class W3_Cdn
  27. {
  28. /**
  29. * Returns W3_Cdn_Base instance
  30. *
  31. * @param string $engine
  32. * @param array $config
  33. * @return W3_Cdn_Base
  34. */
  35. function &instance($engine, $config = array())
  36. {
  37. static $instances = array();
  38. $instance_key = sprintf('%s_%s', $engine, md5(serialize($config)));
  39. if (!isset($instances[$instance_key])) {
  40. switch (true) {
  41. case ($engine == W3_CDN_FTP) :
  42. require_once W3TC_LIB_W3_DIR . '/Cdn/Ftp.php';
  43. $instances[$instance_key] = & new W3_Cdn_Ftp($config);
  44. break;
  45. case (W3TC_PHP5 && $engine == W3_CDN_S3) :
  46. require_once W3TC_LIB_W3_DIR . '/Cdn/S3.php';
  47. $instances[$instance_key] = & new W3_Cdn_S3($config);
  48. break;
  49. case (W3TC_PHP5 && $engine == W3_CDN_CF) :
  50. require_once W3TC_LIB_W3_DIR . '/Cdn/Cf.php';
  51. $instances[$instance_key] = & new W3_Cdn_Cf($config);
  52. break;
  53. case (W3TC_PHP5 && $engine == W3_CDN_RSCF) :
  54. require_once W3TC_LIB_W3_DIR . '/Cdn/Rscf.php';
  55. $instances[$instance_key] = & new W3_Cdn_Rscf($config);
  56. break;
  57. case ($engine == W3_CDN_MIRROR) :
  58. require_once W3TC_LIB_W3_DIR . '/Cdn/Mirror.php';
  59. $instances[$instance_key] = & new W3_Cdn_Mirror($config);
  60. break;
  61. case ($engine == W3_CDN_NETDNA) :
  62. require_once W3TC_LIB_W3_DIR . '/Cdn/Netdna.php';
  63. $instances[$instance_key] = & new W3_Cdn_Netdna($config);
  64. break;
  65. default :
  66. trigger_error('Incorrect CDN engine', E_USER_WARNING);
  67. require_once W3TC_LIB_W3_DIR . '/Cdn/Base.php';
  68. $instances[$instance_key] = & new W3_Cdn_Base();
  69. break;
  70. }
  71. }
  72. return $instances[$instance_key];
  73. }
  74. }