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

Language PHP Lines 92
MD5 Hash 58906b16256fc2da7282afb504d95188 Estimated Cost $1,408 (why?)
Repository https://bitbucket.org/openfarmtech/weblog-content View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php

/**
 * W3 CDN Class
 */

if (!defined('W3_CDN_FTP')) {
    define('W3_CDN_FTP', 'ftp');
}

if (!defined('W3_CDN_CF')) {
    define('W3_CDN_CF', 'cf');
}

if (!defined('W3_CDN_S3')) {
    define('W3_CDN_S3', 's3');
}

if (!defined('W3_CDN_MIRROR')) {
    define('W3_CDN_MIRROR', 'mirror');
}

if (!defined('W3_CDN_NETDNA')) {
    define('W3_CDN_NETDNA', 'netdna');
}

if (!defined('W3_CDN_RSCF')) {
    define('W3_CDN_RSCF', 'rscf');
}

/**
 * Class W3_Cdn
 */
class W3_Cdn
{
    /**
     * Returns W3_Cdn_Base instance
     *
     * @param string $engine
     * @param array $config
     * @return W3_Cdn_Base
     */
    function &instance($engine, $config = array())
    {
        static $instances = array();
        
        $instance_key = sprintf('%s_%s', $engine, md5(serialize($config)));
        
        if (!isset($instances[$instance_key])) {
            switch (true) {
                case ($engine == W3_CDN_FTP) :
                    require_once W3TC_LIB_W3_DIR . '/Cdn/Ftp.php';
                    $instances[$instance_key] = & new W3_Cdn_Ftp($config);
                    break;
                
                case (W3TC_PHP5 && $engine == W3_CDN_S3) :
                    require_once W3TC_LIB_W3_DIR . '/Cdn/S3.php';
                    $instances[$instance_key] = & new W3_Cdn_S3($config);
                    break;
                
                case (W3TC_PHP5 && $engine == W3_CDN_CF) :
                    require_once W3TC_LIB_W3_DIR . '/Cdn/Cf.php';
                    $instances[$instance_key] = & new W3_Cdn_Cf($config);
                    break;
                
                case (W3TC_PHP5 && $engine == W3_CDN_RSCF) :
                    require_once W3TC_LIB_W3_DIR . '/Cdn/Rscf.php';
                    $instances[$instance_key] = & new W3_Cdn_Rscf($config);
                    break;
                
                case ($engine == W3_CDN_MIRROR) :
                    require_once W3TC_LIB_W3_DIR . '/Cdn/Mirror.php';
                    $instances[$instance_key] = & new W3_Cdn_Mirror($config);
                    break;
                
                case ($engine == W3_CDN_NETDNA) :
                    require_once W3TC_LIB_W3_DIR . '/Cdn/Netdna.php';
                    $instances[$instance_key] = & new W3_Cdn_Netdna($config);
                    break;
                
                default :
                    trigger_error('Incorrect CDN engine', E_USER_WARNING);
                    require_once W3TC_LIB_W3_DIR . '/Cdn/Base.php';
                    $instances[$instance_key] = & new W3_Cdn_Base();
                    break;
            }
        }
        
        return $instances[$instance_key];
    }
}
Back to Top