@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** This file is part of KCFinder project |
4 | - * |
|
5 | - * @desc Load language labels into JavaScript |
|
6 | - * @package KCFinder |
|
7 | - * @version 2.54 |
|
8 | - * @author Pavel Tzonkov <[email protected]> |
|
9 | - * @copyright 2010-2014 KCFinder Project |
|
10 | - * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | - * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | - * @link http://kcfinder.sunhater.com |
|
13 | - */ |
|
4 | + * |
|
5 | + * @desc Load language labels into JavaScript |
|
6 | + * @package KCFinder |
|
7 | + * @version 2.54 |
|
8 | + * @author Pavel Tzonkov <[email protected]> |
|
9 | + * @copyright 2010-2014 KCFinder Project |
|
10 | + * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | + * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | + * @link http://kcfinder.sunhater.com |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | require "core/autoload.php"; |
16 | 16 | $input = new input(); |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | header("Content-Type: text/javascript"); |
19 | 19 | die; |
20 | 20 | } |
21 | -$file = "lang/" . $input->get['lng'] . ".php"; |
|
21 | +$file = "lang/".$input->get['lng'].".php"; |
|
22 | 22 | $files = dir::content("lang", array( |
23 | 23 | 'types' => "file", |
24 | 24 | 'pattern' => '/^.*\.php$/' |
@@ -33,4 +33,4 @@ discard block |
||
33 | 33 | header("Content-Type: text/javascript; charset={$lang['_charset']}"); |
34 | 34 | foreach ($lang as $english => $native) |
35 | 35 | if (substr($english, 0, 1) != "_") |
36 | - echo "browser.labels['" . text::jsValue($english) . "']=\"" . text::jsValue($native) . "\";"; |
|
36 | + echo "browser.labels['".text::jsValue($english)."']=\"".text::jsValue($native)."\";"; |
@@ -28,9 +28,12 @@ |
||
28 | 28 | die; |
29 | 29 | } |
30 | 30 | $mtime = @filemtime($file); |
31 | -if ($mtime) httpCache::checkMTime($mtime); |
|
31 | +if ($mtime) { |
|
32 | + httpCache::checkMTime($mtime); |
|
33 | +} |
|
32 | 34 | require $file; |
33 | 35 | header("Content-Type: text/javascript; charset={$lang['_charset']}"); |
34 | -foreach ($lang as $english => $native) |
|
36 | +foreach ($lang as $english => $native) { |
|
35 | 37 | if (substr($english, 0, 1) != "_") |
36 | 38 | echo "browser.labels['" . text::jsValue($english) . "']=\"" . text::jsValue($native) . "\";"; |
39 | +} |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** This file is part of KCFinder project |
4 | - * |
|
5 | - * @desc Join all JavaScript files in current directory |
|
6 | - * @package KCFinder |
|
7 | - * @version 2.54 |
|
8 | - * @author Pavel Tzonkov <[email protected]> |
|
9 | - * @copyright 2010-2014 KCFinder Project |
|
10 | - * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | - * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | - * @link http://kcfinder.sunhater.com |
|
13 | - */ |
|
4 | + * |
|
5 | + * @desc Join all JavaScript files in current directory |
|
6 | + * @package KCFinder |
|
7 | + * @version 2.54 |
|
8 | + * @author Pavel Tzonkov <[email protected]> |
|
9 | + * @copyright 2010-2014 KCFinder Project |
|
10 | + * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | + * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | + * @link http://kcfinder.sunhater.com |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | chdir(".."); // For compatibility |
16 | 16 | chdir(".."); |
@@ -23,11 +23,13 @@ |
||
23 | 23 | |
24 | 24 | foreach ($files as $file) { |
25 | 25 | $fmtime = filemtime($file); |
26 | - if (!isset($mtime) || ($fmtime > $mtime)) |
|
27 | - $mtime = $fmtime; |
|
28 | -} |
|
26 | + if (!isset($mtime) || ($fmtime > $mtime)) { |
|
27 | + $mtime = $fmtime; |
|
28 | + } |
|
29 | + } |
|
29 | 30 | |
30 | 31 | httpCache::checkMTime($mtime); |
31 | 32 | header("Content-Type: text/javascript"); |
32 | -foreach ($files as $file) |
|
33 | +foreach ($files as $file) { |
|
33 | 34 | require $file; |
35 | +} |
@@ -10,14 +10,14 @@ |
||
10 | 10 | } |
11 | 11 | }; |
12 | 12 | <?php |
13 | - if(isset($_GET['type'])) $type = htmlspecialchars(trim($_GET['type']), ENT_QUOTES); |
|
14 | - elseif(isset($_GET['Type'])) $type = htmlspecialchars(trim($_GET['Type']), ENT_QUOTES); |
|
13 | + if(isset($_GET['type'])) $type = htmlspecialchars(trim($_GET['type']), ENT_QUOTES); |
|
14 | + elseif(isset($_GET['Type'])) $type = htmlspecialchars(trim($_GET['Type']), ENT_QUOTES); |
|
15 | 15 | else $type = 'images'; |
16 | 16 | |
17 | 17 | if($type==='image') $type = 'images'; |
18 | 18 | |
19 | - $opener = (isset($_GET['editor'])) ? 'opener=' . htmlspecialchars(trim($_GET['editor']), ENT_QUOTES) : ''; |
|
20 | - $request_uri = "{$opener}&type={$type}"; |
|
19 | + $opener = (isset($_GET['editor'])) ? 'opener=' . htmlspecialchars(trim($_GET['editor']), ENT_QUOTES) : ''; |
|
20 | + $request_uri = "{$opener}&type={$type}"; |
|
21 | 21 | ?> |
22 | 22 | window.location.href = "browse.php?<?php echo $request_uri; ?>"; |
23 | 23 | </script> |
@@ -10,13 +10,13 @@ |
||
10 | 10 | } |
11 | 11 | }; |
12 | 12 | <?php |
13 | - if(isset($_GET['type'])) $type = htmlspecialchars(trim($_GET['type']), ENT_QUOTES); |
|
14 | - elseif(isset($_GET['Type'])) $type = htmlspecialchars(trim($_GET['Type']), ENT_QUOTES); |
|
13 | + if (isset($_GET['type'])) $type = htmlspecialchars(trim($_GET['type']), ENT_QUOTES); |
|
14 | + elseif (isset($_GET['Type'])) $type = htmlspecialchars(trim($_GET['Type']), ENT_QUOTES); |
|
15 | 15 | else $type = 'images'; |
16 | 16 | |
17 | - if($type==='image') $type = 'images'; |
|
17 | + if ($type === 'image') $type = 'images'; |
|
18 | 18 | |
19 | - $opener = (isset($_GET['editor'])) ? 'opener=' . htmlspecialchars(trim($_GET['editor']), ENT_QUOTES) : ''; |
|
19 | + $opener = (isset($_GET['editor'])) ? 'opener='.htmlspecialchars(trim($_GET['editor']), ENT_QUOTES) : ''; |
|
20 | 20 | $request_uri = "{$opener}&type={$type}"; |
21 | 21 | ?> |
22 | 22 | window.location.href = "browse.php?<?php echo $request_uri; ?>"; |
@@ -10,11 +10,17 @@ |
||
10 | 10 | } |
11 | 11 | }; |
12 | 12 | <?php |
13 | - if(isset($_GET['type'])) $type = htmlspecialchars(trim($_GET['type']), ENT_QUOTES); |
|
14 | - elseif(isset($_GET['Type'])) $type = htmlspecialchars(trim($_GET['Type']), ENT_QUOTES); |
|
15 | - else $type = 'images'; |
|
13 | + if(isset($_GET['type'])) { |
|
14 | + $type = htmlspecialchars(trim($_GET['type']), ENT_QUOTES); |
|
15 | + } elseif(isset($_GET['Type'])) { |
|
16 | + $type = htmlspecialchars(trim($_GET['Type']), ENT_QUOTES); |
|
17 | + } else { |
|
18 | + $type = 'images'; |
|
19 | + } |
|
16 | 20 | |
17 | - if($type==='image') $type = 'images'; |
|
21 | + if($type==='image') { |
|
22 | + $type = 'images'; |
|
23 | + } |
|
18 | 24 | |
19 | 25 | $opener = (isset($_GET['editor'])) ? 'opener=' . htmlspecialchars(trim($_GET['editor']), ENT_QUOTES) : ''; |
20 | 26 | $request_uri = "{$opener}&type={$type}"; |
@@ -1,23 +1,23 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** This file is part of KCFinder project |
4 | - * |
|
5 | - * @desc Directory helper class |
|
6 | - * @package KCFinder |
|
7 | - * @version 2.54 |
|
8 | - * @author Pavel Tzonkov <[email protected]> |
|
9 | - * @copyright 2010-2014 KCFinder Project |
|
10 | - * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | - * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | - * @link http://kcfinder.sunhater.com |
|
13 | - */ |
|
4 | + * |
|
5 | + * @desc Directory helper class |
|
6 | + * @package KCFinder |
|
7 | + * @version 2.54 |
|
8 | + * @author Pavel Tzonkov <[email protected]> |
|
9 | + * @copyright 2010-2014 KCFinder Project |
|
10 | + * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | + * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | + * @link http://kcfinder.sunhater.com |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | class dir { |
16 | 16 | |
17 | - /** Checks if the given directory is really writable. The standard PHP |
|
18 | - * function is_writable() does not work properly on Windows servers |
|
19 | - * @param string $dir |
|
20 | - * @return bool */ |
|
17 | + /** Checks if the given directory is really writable. The standard PHP |
|
18 | + * function is_writable() does not work properly on Windows servers |
|
19 | + * @param string $dir |
|
20 | + * @return bool */ |
|
21 | 21 | |
22 | 22 | static function isWritable($dir) { |
23 | 23 | $dir = path::normalize($dir); |
@@ -33,16 +33,16 @@ discard block |
||
33 | 33 | return true; |
34 | 34 | } |
35 | 35 | |
36 | - /** Recursively delete the given directory. Returns TRUE on success. |
|
37 | - * If $firstFailExit parameter is true (default), the method returns the |
|
38 | - * path to the first failed file or directory which cannot be deleted. |
|
39 | - * If $firstFailExit is false, the method returns an array with failed |
|
40 | - * files and directories which cannot be deleted. The third parameter |
|
41 | - * $failed is used for internal use only. |
|
42 | - * @param string $dir |
|
43 | - * @param bool $firstFailExit |
|
44 | - * @param array $failed |
|
45 | - * @return mixed */ |
|
36 | + /** Recursively delete the given directory. Returns TRUE on success. |
|
37 | + * If $firstFailExit parameter is true (default), the method returns the |
|
38 | + * path to the first failed file or directory which cannot be deleted. |
|
39 | + * If $firstFailExit is false, the method returns an array with failed |
|
40 | + * files and directories which cannot be deleted. The third parameter |
|
41 | + * $failed is used for internal use only. |
|
42 | + * @param string $dir |
|
43 | + * @param bool $firstFailExit |
|
44 | + * @param array $failed |
|
45 | + * @return mixed */ |
|
46 | 46 | |
47 | 47 | static function prune($dir, $firstFailExit=true, array $failed=null) { |
48 | 48 | if ($failed === null) $failed = array(); |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | return count($failed) ? $failed : true; |
82 | 82 | } |
83 | 83 | |
84 | - /** Get the content of the given directory. Returns an array with filenames |
|
85 | - * or FALSE on failure |
|
86 | - * @param string $dir |
|
87 | - * @param array $options |
|
88 | - * @return mixed */ |
|
84 | + /** Get the content of the given directory. Returns an array with filenames |
|
85 | + * or FALSE on failure |
|
86 | + * @param string $dir |
|
87 | + * @param array $options |
|
88 | + * @return mixed */ |
|
89 | 89 | |
90 | 90 | static function content($dir, array $options=null) { |
91 | 91 |
@@ -12,20 +12,20 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class dir { |
|
15 | +class dir{ |
|
16 | 16 | |
17 | 17 | /** Checks if the given directory is really writable. The standard PHP |
18 | 18 | * function is_writable() does not work properly on Windows servers |
19 | 19 | * @param string $dir |
20 | 20 | * @return bool */ |
21 | 21 | |
22 | - static function isWritable($dir) { |
|
22 | + static function isWritable($dir){ |
|
23 | 23 | $dir = path::normalize($dir); |
24 | 24 | if (!is_dir($dir)) |
25 | 25 | return false; |
26 | 26 | $i = 0; |
27 | 27 | do { |
28 | - $file = "$dir/is_writable_" . md5($i++); |
|
28 | + $file = "$dir/is_writable_".md5($i++); |
|
29 | 29 | } while (file_exists($file)); |
30 | 30 | if (!@touch($file)) |
31 | 31 | return false; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param array $failed |
45 | 45 | * @return mixed */ |
46 | 46 | |
47 | - static function prune($dir, $firstFailExit=true, array $failed=null) { |
|
47 | + static function prune($dir, $firstFailExit = true, array $failed = null){ |
|
48 | 48 | if ($failed === null) $failed = array(); |
49 | 49 | $files = self::content($dir); |
50 | 50 | if ($files === false) { |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | * @param array $options |
88 | 88 | * @return mixed */ |
89 | 89 | |
90 | - static function content($dir, array $options=null) { |
|
90 | + static function content($dir, array $options = null){ |
|
91 | 91 | |
92 | 92 | $defaultOptions = array( |
93 | - 'types' => "all", // Allowed: "all" or possible return values |
|
93 | + 'types' => "all", // Allowed: "all" or possible return values |
|
94 | 94 | // of filetype(), or an array with them |
95 | - 'addPath' => true, // Whether to add directory path to filenames |
|
95 | + 'addPath' => true, // Whether to add directory path to filenames |
|
96 | 96 | 'pattern' => '/./', // Regular expression pattern for filename |
97 | 97 | 'followLinks' => true |
98 | 98 | ); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | return $files; |
146 | 146 | } |
147 | 147 | |
148 | - static function fileSort($a, $b) { |
|
148 | + static function fileSort($a, $b){ |
|
149 | 149 | if (function_exists("mb_strtolower")) { |
150 | 150 | $a = mb_strtolower($a); |
151 | 151 | $b = mb_strtolower($b); |
@@ -12,23 +12,27 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class dir { |
|
15 | +class dir |
|
16 | +{ |
|
16 | 17 | |
17 | 18 | /** Checks if the given directory is really writable. The standard PHP |
18 | 19 | * function is_writable() does not work properly on Windows servers |
19 | 20 | * @param string $dir |
20 | 21 | * @return bool */ |
21 | 22 | |
22 | - static function isWritable($dir) { |
|
23 | + static function isWritable($dir) |
|
24 | + { |
|
23 | 25 | $dir = path::normalize($dir); |
24 | - if (!is_dir($dir)) |
|
25 | - return false; |
|
26 | + if (!is_dir($dir)) { |
|
27 | + return false; |
|
28 | + } |
|
26 | 29 | $i = 0; |
27 | 30 | do { |
28 | 31 | $file = "$dir/is_writable_" . md5($i++); |
29 | 32 | } while (file_exists($file)); |
30 | - if (!@touch($file)) |
|
31 | - return false; |
|
33 | + if (!@touch($file)) { |
|
34 | + return false; |
|
35 | + } |
|
32 | 36 | unlink($file); |
33 | 37 | return true; |
34 | 38 | } |
@@ -44,12 +48,16 @@ discard block |
||
44 | 48 | * @param array $failed |
45 | 49 | * @return mixed */ |
46 | 50 | |
47 | - static function prune($dir, $firstFailExit=true, array $failed=null) { |
|
48 | - if ($failed === null) $failed = array(); |
|
51 | + static function prune($dir, $firstFailExit=true, array $failed=null) |
|
52 | + { |
|
53 | + if ($failed === null) { |
|
54 | + $failed = array(); |
|
55 | + } |
|
49 | 56 | $files = self::content($dir); |
50 | 57 | if ($files === false) { |
51 | - if ($firstFailExit) |
|
52 | - return $dir; |
|
58 | + if ($firstFailExit) { |
|
59 | + return $dir; |
|
60 | + } |
|
53 | 61 | $failed[] = $dir; |
54 | 62 | return $failed; |
55 | 63 | } |
@@ -58,23 +66,27 @@ discard block |
||
58 | 66 | if (is_dir($file)) { |
59 | 67 | $failed_in = self::prune($file, $firstFailExit, $failed); |
60 | 68 | if ($failed_in !== true) { |
61 | - if ($firstFailExit) |
|
62 | - return $failed_in; |
|
63 | - if (is_array($failed_in)) |
|
64 | - $failed = array_merge($failed, $failed_in); |
|
65 | - else |
|
66 | - $failed[] = $failed_in; |
|
69 | + if ($firstFailExit) { |
|
70 | + return $failed_in; |
|
71 | + } |
|
72 | + if (is_array($failed_in)) { |
|
73 | + $failed = array_merge($failed, $failed_in); |
|
74 | + } else { |
|
75 | + $failed[] = $failed_in; |
|
76 | + } |
|
67 | 77 | } |
68 | 78 | } elseif (!@unlink($file)) { |
69 | - if ($firstFailExit) |
|
70 | - return $file; |
|
79 | + if ($firstFailExit) { |
|
80 | + return $file; |
|
81 | + } |
|
71 | 82 | $failed[] = $file; |
72 | 83 | } |
73 | 84 | } |
74 | 85 | |
75 | 86 | if (!@rmdir($dir)) { |
76 | - if ($firstFailExit) |
|
77 | - return $dir; |
|
87 | + if ($firstFailExit) { |
|
88 | + return $dir; |
|
89 | + } |
|
78 | 90 | $failed[] = $dir; |
79 | 91 | } |
80 | 92 | |
@@ -87,7 +99,8 @@ discard block |
||
87 | 99 | * @param array $options |
88 | 100 | * @return mixed */ |
89 | 101 | |
90 | - static function content($dir, array $options=null) { |
|
102 | + static function content($dir, array $options=null) |
|
103 | + { |
|
91 | 104 | |
92 | 105 | $defaultOptions = array( |
93 | 106 | 'types' => "all", // Allowed: "all" or possible return values |
@@ -97,23 +110,28 @@ discard block |
||
97 | 110 | 'followLinks' => true |
98 | 111 | ); |
99 | 112 | |
100 | - if (!is_dir($dir) || !is_readable($dir)) |
|
101 | - return false; |
|
113 | + if (!is_dir($dir) || !is_readable($dir)) { |
|
114 | + return false; |
|
115 | + } |
|
102 | 116 | |
103 | - if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") |
|
104 | - $dir = str_replace("\\", "/", $dir); |
|
117 | + if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") { |
|
118 | + $dir = str_replace("\\", "/", $dir); |
|
119 | + } |
|
105 | 120 | $dir = rtrim($dir, "/"); |
106 | 121 | |
107 | 122 | $dh = @opendir($dir); |
108 | - if ($dh === false) |
|
109 | - return false; |
|
123 | + if ($dh === false) { |
|
124 | + return false; |
|
125 | + } |
|
110 | 126 | |
111 | - if ($options === null) |
|
112 | - $options = $defaultOptions; |
|
127 | + if ($options === null) { |
|
128 | + $options = $defaultOptions; |
|
129 | + } |
|
113 | 130 | |
114 | - foreach ($defaultOptions as $key => $val) |
|
115 | - if (!isset($options[$key])) |
|
131 | + foreach ($defaultOptions as $key => $val) { |
|
132 | + if (!isset($options[$key])) |
|
116 | 133 | $options[$key] = $val; |
134 | + } |
|
117 | 135 | |
118 | 136 | $files = array(); |
119 | 137 | while (($file = @readdir($dh)) !== false) { |
@@ -124,28 +142,32 @@ discard block |
||
124 | 142 | do { |
125 | 143 | $ldir = dirname($lfile); |
126 | 144 | $lfile = @readlink($lfile); |
127 | - if (substr($lfile, 0, 1) != "/") |
|
128 | - $lfile = "$ldir/$lfile"; |
|
145 | + if (substr($lfile, 0, 1) != "/") { |
|
146 | + $lfile = "$ldir/$lfile"; |
|
147 | + } |
|
129 | 148 | $type = filetype($lfile); |
130 | 149 | } while ($type == "link"); |
131 | 150 | } |
132 | 151 | |
133 | 152 | if ((($type === "dir") && (($file == ".") || ($file == ".."))) || |
134 | 153 | !preg_match($options['pattern'], $file) |
135 | - ) |
|
136 | - continue; |
|
154 | + ) { |
|
155 | + continue; |
|
156 | + } |
|
137 | 157 | |
138 | 158 | if (($options['types'] === "all") || ($type === $options['types']) || |
139 | 159 | ((is_array($options['types'])) && in_array($type, $options['types'])) |
140 | - ) |
|
141 | - $files[] = $options['addPath'] ? "$dir/$file" : $file; |
|
160 | + ) { |
|
161 | + $files[] = $options['addPath'] ? "$dir/$file" : $file; |
|
162 | + } |
|
142 | 163 | } |
143 | 164 | closedir($dh); |
144 | 165 | usort($files, array("dir", "fileSort")); |
145 | 166 | return $files; |
146 | 167 | } |
147 | 168 | |
148 | - static function fileSort($a, $b) { |
|
169 | + static function fileSort($a, $b) |
|
170 | + { |
|
149 | 171 | if (function_exists("mb_strtolower")) { |
150 | 172 | $a = mb_strtolower($a); |
151 | 173 | $b = mb_strtolower($b); |
@@ -153,7 +175,9 @@ discard block |
||
153 | 175 | $a = strtolower($a); |
154 | 176 | $b = strtolower($b); |
155 | 177 | } |
156 | - if ($a == $b) return 0; |
|
178 | + if ($a == $b) { |
|
179 | + return 0; |
|
180 | + } |
|
157 | 181 | return ($a < $b) ? -1 : 1; |
158 | 182 | } |
159 | 183 | } |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** This file is part of KCFinder project |
4 | - * |
|
5 | - * @desc ImageMagick image driver class |
|
6 | - * @package KCFinder |
|
7 | - * @version 2.54 |
|
8 | - * @author Pavel Tzonkov <[email protected]> |
|
9 | - * @copyright 2010-2014 KCFinder Project |
|
10 | - * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | - * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | - * @link http://kcfinder.sunhater.com |
|
13 | - */ |
|
4 | + * |
|
5 | + * @desc ImageMagick image driver class |
|
6 | + * @package KCFinder |
|
7 | + * @version 2.54 |
|
8 | + * @author Pavel Tzonkov <[email protected]> |
|
9 | + * @copyright 2010-2014 KCFinder Project |
|
10 | + * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | + * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | + * @link http://kcfinder.sunhater.com |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | class image_imagick extends image { |
16 | 16 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class image_imagick extends image { |
|
15 | +class image_imagick extends image{ |
|
16 | 16 | |
17 | 17 | static $MIMES = array( |
18 | 18 | //'tif' => "image/tiff" |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | // ABSTRACT PUBLIC METHODS |
23 | 23 | |
24 | - public function resize($width, $height) {// |
|
24 | + public function resize($width, $height){// |
|
25 | 25 | if (!$width) $width = 1; |
26 | 26 | if (!$height) $height = 1; |
27 | 27 | try { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | return true; |
35 | 35 | } |
36 | 36 | |
37 | - public function resizeFit($width, $height, $background=false) {// |
|
37 | + public function resizeFit($width, $height, $background = false){// |
|
38 | 38 | if (!$width) $width = 1; |
39 | 39 | if (!$height) $height = 1; |
40 | 40 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | - public function resizeCrop($width, $height, $offset=false) { |
|
68 | + public function resizeCrop($width, $height, $offset = false){ |
|
69 | 69 | if (!$width) $width = 1; |
70 | 70 | if (!$height) $height = 1; |
71 | 71 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | return true; |
116 | 116 | } |
117 | 117 | |
118 | - public function rotate($angle, $background="#000000") { |
|
118 | + public function rotate($angle, $background = "#000000"){ |
|
119 | 119 | try { |
120 | 120 | $this->image->rotateImage(new ImagickPixel($background), $angle); |
121 | 121 | $size = $this->image->getImageGeometry(); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | return true; |
128 | 128 | } |
129 | 129 | |
130 | - public function flipHorizontal() { |
|
130 | + public function flipHorizontal(){ |
|
131 | 131 | try { |
132 | 132 | $this->image->flopImage(); |
133 | 133 | } catch (Exception $e) { |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | return true; |
137 | 137 | } |
138 | 138 | |
139 | - public function flipVertical() { |
|
139 | + public function flipVertical(){ |
|
140 | 140 | try { |
141 | 141 | $this->image->flipImage(); |
142 | 142 | } catch (Exception $e) { |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | return true; |
146 | 146 | } |
147 | 147 | |
148 | - public function watermark($file, $left=false, $top=false) { |
|
148 | + public function watermark($file, $left = false, $top = false){ |
|
149 | 149 | try { |
150 | 150 | $wm = new Imagick($file); |
151 | 151 | $size = $wm->getImageGeometry(); |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | |
182 | 182 | // ABSTRACT PROTECTED METHODS |
183 | 183 | |
184 | - protected function getBlankImage($width, $height) { |
|
184 | + protected function getBlankImage($width, $height){ |
|
185 | 185 | try { |
186 | 186 | $img = new Imagick(); |
187 | 187 | $img->newImage($width, $height, "none"); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | return $img; |
193 | 193 | } |
194 | 194 | |
195 | - protected function getImage($image, &$width, &$height) { |
|
195 | + protected function getImage($image, &$width, &$height){ |
|
196 | 196 | |
197 | 197 | if (is_object($image) && ($image instanceof image_imagick)) { |
198 | 198 | try { |
@@ -234,11 +234,11 @@ discard block |
||
234 | 234 | |
235 | 235 | // PSEUDO-ABSTRACT STATIC METHODS |
236 | 236 | |
237 | - static function available() { |
|
237 | + static function available(){ |
|
238 | 238 | return class_exists("Imagick"); |
239 | 239 | } |
240 | 240 | |
241 | - static function checkImage($file) { |
|
241 | + static function checkImage($file){ |
|
242 | 242 | try { |
243 | 243 | new Imagick($file); |
244 | 244 | } catch (Exception $e) { |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | |
251 | 251 | // INHERIT METHODS |
252 | 252 | |
253 | - public function output($type="jpeg", array $options=array()) { |
|
253 | + public function output($type = "jpeg", array $options = array()){ |
|
254 | 254 | $type = strtolower($type); |
255 | 255 | try { |
256 | 256 | $this->image->setImageFormat($type); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | echo $this->image; |
270 | 270 | |
271 | 271 | } else { |
272 | - $file = $options['file'] . ".$type"; |
|
272 | + $file = $options['file'].".$type"; |
|
273 | 273 | try { |
274 | 274 | $this->image->writeImage($file); |
275 | 275 | } catch (Exception $e) { |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | |
290 | 290 | // OWN METHODS |
291 | 291 | |
292 | - protected function optimize_jpeg(array $options=array()) { |
|
292 | + protected function optimize_jpeg(array $options = array()){ |
|
293 | 293 | $quality = isset($options['quality']) ? $options['quality'] : self::DEFAULT_JPEG_QUALITY; |
294 | 294 | try { |
295 | 295 | $this->image->setImageCompression(Imagick::COMPRESSION_JPEG); |
@@ -12,7 +12,8 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class image_imagick extends image { |
|
15 | +class image_imagick extends image |
|
16 | +{ |
|
16 | 17 | |
17 | 18 | static $MIMES = array( |
18 | 19 | //'tif' => "image/tiff" |
@@ -21,9 +22,15 @@ discard block |
||
21 | 22 | |
22 | 23 | // ABSTRACT PUBLIC METHODS |
23 | 24 | |
24 | - public function resize($width, $height) {// |
|
25 | - if (!$width) $width = 1; |
|
26 | - if (!$height) $height = 1; |
|
25 | + public function resize($width, $height) |
|
26 | + { |
|
27 | +// |
|
28 | + if (!$width) { |
|
29 | + $width = 1; |
|
30 | + } |
|
31 | + if (!$height) { |
|
32 | + $height = 1; |
|
33 | + } |
|
27 | 34 | try { |
28 | 35 | $this->image->scaleImage($width, $height); |
29 | 36 | } catch (Exception $e) { |
@@ -34,9 +41,15 @@ discard block |
||
34 | 41 | return true; |
35 | 42 | } |
36 | 43 | |
37 | - public function resizeFit($width, $height, $background=false) {// |
|
38 | - if (!$width) $width = 1; |
|
39 | - if (!$height) $height = 1; |
|
44 | + public function resizeFit($width, $height, $background=false) |
|
45 | + { |
|
46 | +// |
|
47 | + if (!$width) { |
|
48 | + $width = 1; |
|
49 | + } |
|
50 | + if (!$height) { |
|
51 | + $height = 1; |
|
52 | + } |
|
40 | 53 | |
41 | 54 | try { |
42 | 55 | $this->image->scaleImage($width, $height, true); |
@@ -65,43 +78,58 @@ discard block |
||
65 | 78 | } |
66 | 79 | } |
67 | 80 | |
68 | - public function resizeCrop($width, $height, $offset=false) { |
|
69 | - if (!$width) $width = 1; |
|
70 | - if (!$height) $height = 1; |
|
81 | + public function resizeCrop($width, $height, $offset=false) |
|
82 | + { |
|
83 | + if (!$width) { |
|
84 | + $width = 1; |
|
85 | + } |
|
86 | + if (!$height) { |
|
87 | + $height = 1; |
|
88 | + } |
|
71 | 89 | |
72 | 90 | if (($this->width / $this->height) > ($width / $height)) { |
73 | 91 | $h = $height; |
74 | 92 | $w = ($this->width * $h) / $this->height; |
75 | 93 | $y = 0; |
76 | 94 | if ($offset !== false) { |
77 | - if ($offset > 0) |
|
78 | - $offset = -$offset; |
|
79 | - if (($w + $offset) <= $width) |
|
80 | - $offset = $width - $w; |
|
95 | + if ($offset > 0) { |
|
96 | + $offset = -$offset; |
|
97 | + } |
|
98 | + if (($w + $offset) <= $width) { |
|
99 | + $offset = $width - $w; |
|
100 | + } |
|
81 | 101 | $x = $offset; |
82 | - } else |
|
83 | - $x = ($width - $w) / 2; |
|
102 | + } else { |
|
103 | + $x = ($width - $w) / 2; |
|
104 | + } |
|
84 | 105 | |
85 | 106 | } else { |
86 | 107 | $w = $width; |
87 | 108 | $h = ($this->height * $w) / $this->width; |
88 | 109 | $x = 0; |
89 | 110 | if ($offset !== false) { |
90 | - if ($offset > 0) |
|
91 | - $offset = -$offset; |
|
92 | - if (($h + $offset) <= $height) |
|
93 | - $offset = $height - $h; |
|
111 | + if ($offset > 0) { |
|
112 | + $offset = -$offset; |
|
113 | + } |
|
114 | + if (($h + $offset) <= $height) { |
|
115 | + $offset = $height - $h; |
|
116 | + } |
|
94 | 117 | $y = $offset; |
95 | - } else |
|
96 | - $y = ($height - $h) / 2; |
|
118 | + } else { |
|
119 | + $y = ($height - $h) / 2; |
|
120 | + } |
|
97 | 121 | } |
98 | 122 | |
99 | 123 | $x = round($x); |
100 | 124 | $y = round($y); |
101 | 125 | $w = round($w); |
102 | 126 | $h = round($h); |
103 | - if (!$w) $w = 1; |
|
104 | - if (!$h) $h = 1; |
|
127 | + if (!$w) { |
|
128 | + $w = 1; |
|
129 | + } |
|
130 | + if (!$h) { |
|
131 | + $h = 1; |
|
132 | + } |
|
105 | 133 | |
106 | 134 | try { |
107 | 135 | $this->image->scaleImage($w, $h); |
@@ -115,7 +143,8 @@ discard block |
||
115 | 143 | return true; |
116 | 144 | } |
117 | 145 | |
118 | - public function rotate($angle, $background="#000000") { |
|
146 | + public function rotate($angle, $background="#000000") |
|
147 | + { |
|
119 | 148 | try { |
120 | 149 | $this->image->rotateImage(new ImagickPixel($background), $angle); |
121 | 150 | $size = $this->image->getImageGeometry(); |
@@ -127,7 +156,8 @@ discard block |
||
127 | 156 | return true; |
128 | 157 | } |
129 | 158 | |
130 | - public function flipHorizontal() { |
|
159 | + public function flipHorizontal() |
|
160 | + { |
|
131 | 161 | try { |
132 | 162 | $this->image->flopImage(); |
133 | 163 | } catch (Exception $e) { |
@@ -136,7 +166,8 @@ discard block |
||
136 | 166 | return true; |
137 | 167 | } |
138 | 168 | |
139 | - public function flipVertical() { |
|
169 | + public function flipVertical() |
|
170 | + { |
|
140 | 171 | try { |
141 | 172 | $this->image->flipImage(); |
142 | 173 | } catch (Exception $e) { |
@@ -145,7 +176,8 @@ discard block |
||
145 | 176 | return true; |
146 | 177 | } |
147 | 178 | |
148 | - public function watermark($file, $left=false, $top=false) { |
|
179 | + public function watermark($file, $left=false, $top=false) |
|
180 | + { |
|
149 | 181 | try { |
150 | 182 | $wm = new Imagick($file); |
151 | 183 | $size = $wm->getImageGeometry(); |
@@ -167,8 +199,9 @@ discard block |
||
167 | 199 | if ((($x + $w) > $this->width) || |
168 | 200 | (($y + $h) > $this->height) || |
169 | 201 | ($x < 0) || ($y < 0) |
170 | - ) |
|
171 | - return false; |
|
202 | + ) { |
|
203 | + return false; |
|
204 | + } |
|
172 | 205 | |
173 | 206 | try { |
174 | 207 | $this->image->compositeImage($wm, Imagick::COMPOSITE_DEFAULT, $x, $y); |
@@ -181,7 +214,8 @@ discard block |
||
181 | 214 | |
182 | 215 | // ABSTRACT PROTECTED METHODS |
183 | 216 | |
184 | - protected function getBlankImage($width, $height) { |
|
217 | + protected function getBlankImage($width, $height) |
|
218 | + { |
|
185 | 219 | try { |
186 | 220 | $img = new Imagick(); |
187 | 221 | $img->newImage($width, $height, "none"); |
@@ -192,7 +226,8 @@ discard block |
||
192 | 226 | return $img; |
193 | 227 | } |
194 | 228 | |
195 | - protected function getImage($image, &$width, &$height) { |
|
229 | + protected function getImage($image, &$width, &$height) |
|
230 | + { |
|
196 | 231 | |
197 | 232 | if (is_object($image) && ($image instanceof image_imagick)) { |
198 | 233 | try { |
@@ -227,18 +262,21 @@ discard block |
||
227 | 262 | $height = $size['height']; |
228 | 263 | return $image; |
229 | 264 | |
230 | - } else |
|
231 | - return false; |
|
265 | + } else { |
|
266 | + return false; |
|
267 | + } |
|
232 | 268 | } |
233 | 269 | |
234 | 270 | |
235 | 271 | // PSEUDO-ABSTRACT STATIC METHODS |
236 | 272 | |
237 | - static function available() { |
|
273 | + static function available() |
|
274 | + { |
|
238 | 275 | return class_exists("Imagick"); |
239 | 276 | } |
240 | 277 | |
241 | - static function checkImage($file) { |
|
278 | + static function checkImage($file) |
|
279 | + { |
|
242 | 280 | try { |
243 | 281 | new Imagick($file); |
244 | 282 | } catch (Exception $e) { |
@@ -250,7 +288,8 @@ discard block |
||
250 | 288 | |
251 | 289 | // INHERIT METHODS |
252 | 290 | |
253 | - public function output($type="jpeg", array $options=array()) { |
|
291 | + public function output($type="jpeg", array $options=array()) |
|
292 | + { |
|
254 | 293 | $type = strtolower($type); |
255 | 294 | try { |
256 | 295 | $this->image->setImageFormat($type); |
@@ -258,8 +297,9 @@ discard block |
||
258 | 297 | return false; |
259 | 298 | } |
260 | 299 | $method = "optimize_$type"; |
261 | - if (method_exists($this, $method) && !$this->$method($options)) |
|
262 | - return false; |
|
300 | + if (method_exists($this, $method) && !$this->$method($options)) { |
|
301 | + return false; |
|
302 | + } |
|
263 | 303 | |
264 | 304 | if (!isset($options['file'])) { |
265 | 305 | if (!headers_sent()) { |
@@ -289,7 +329,8 @@ discard block |
||
289 | 329 | |
290 | 330 | // OWN METHODS |
291 | 331 | |
292 | - protected function optimize_jpeg(array $options=array()) { |
|
332 | + protected function optimize_jpeg(array $options=array()) |
|
333 | + { |
|
293 | 334 | $quality = isset($options['quality']) ? $options['quality'] : self::DEFAULT_JPEG_QUALITY; |
294 | 335 | try { |
295 | 336 | $this->image->setImageCompression(Imagick::COMPRESSION_JPEG); |
@@ -1,29 +1,29 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** This file is part of KCFinder project |
4 | - * |
|
5 | - * @desc Input class for GET, POST and COOKIE requests |
|
6 | - * @package KCFinder |
|
7 | - * @version 2.54 |
|
8 | - * @author Pavel Tzonkov <[email protected]> |
|
9 | - * @copyright 2010-2014 KCFinder Project |
|
10 | - * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | - * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | - * @link http://kcfinder.sunhater.com |
|
13 | - */ |
|
4 | + * |
|
5 | + * @desc Input class for GET, POST and COOKIE requests |
|
6 | + * @package KCFinder |
|
7 | + * @version 2.54 |
|
8 | + * @author Pavel Tzonkov <[email protected]> |
|
9 | + * @copyright 2010-2014 KCFinder Project |
|
10 | + * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | + * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | + * @link http://kcfinder.sunhater.com |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | class input { |
16 | 16 | |
17 | - /** Filtered $_GET array |
|
18 | - * @var array */ |
|
17 | + /** Filtered $_GET array |
|
18 | + * @var array */ |
|
19 | 19 | public $get; |
20 | 20 | |
21 | - /** Filtered $_POST array |
|
22 | - * @var array */ |
|
21 | + /** Filtered $_POST array |
|
22 | + * @var array */ |
|
23 | 23 | public $post; |
24 | 24 | |
25 | - /** Filtered $_COOKIE array |
|
26 | - * @var array */ |
|
25 | + /** Filtered $_COOKIE array |
|
26 | + * @var array */ |
|
27 | 27 | public $cookie; |
28 | 28 | |
29 | 29 | public function __construct() { |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | $this->cookie = &$_COOKIE; |
33 | 33 | } |
34 | 34 | |
35 | - /** Magic method to get non-public properties like public. |
|
36 | - * @param string $property |
|
37 | - * @return mixed */ |
|
35 | + /** Magic method to get non-public properties like public. |
|
36 | + * @param string $property |
|
37 | + * @return mixed */ |
|
38 | 38 | |
39 | 39 | public function __get($property) { |
40 | 40 | return property_exists($this, $property) ? $this->$property : null; |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class input { |
|
15 | +class input{ |
|
16 | 16 | |
17 | 17 | /** Filtered $_GET array |
18 | 18 | * @var array */ |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @var array */ |
27 | 27 | public $cookie; |
28 | 28 | |
29 | - public function __construct() { |
|
29 | + public function __construct(){ |
|
30 | 30 | $this->get = &$_GET; |
31 | 31 | $this->post = &$_POST; |
32 | 32 | $this->cookie = &$_COOKIE; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param string $property |
37 | 37 | * @return mixed */ |
38 | 38 | |
39 | - public function __get($property) { |
|
39 | + public function __get($property){ |
|
40 | 40 | return property_exists($this, $property) ? $this->$property : null; |
41 | 41 | } |
42 | 42 | } |
@@ -12,7 +12,8 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class input { |
|
15 | +class input |
|
16 | +{ |
|
16 | 17 | |
17 | 18 | /** Filtered $_GET array |
18 | 19 | * @var array */ |
@@ -26,7 +27,8 @@ discard block |
||
26 | 27 | * @var array */ |
27 | 28 | public $cookie; |
28 | 29 | |
29 | - public function __construct() { |
|
30 | + public function __construct() |
|
31 | + { |
|
30 | 32 | $this->get = &$_GET; |
31 | 33 | $this->post = &$_POST; |
32 | 34 | $this->cookie = &$_COOKIE; |
@@ -36,7 +38,8 @@ discard block |
||
36 | 38 | * @param string $property |
37 | 39 | * @return mixed */ |
38 | 40 | |
39 | - public function __get($property) { |
|
41 | + public function __get($property) |
|
42 | + { |
|
40 | 43 | return property_exists($this, $property) ? $this->$property : null; |
41 | 44 | } |
42 | 45 | } |
@@ -1,23 +1,23 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** This file is part of KCFinder project |
4 | - * |
|
5 | - * @desc Path helper class |
|
6 | - * @package KCFinder |
|
7 | - * @version 2.54 |
|
8 | - * @author Pavel Tzonkov <[email protected]> |
|
9 | - * @copyright 2010-2014 KCFinder Project |
|
10 | - * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | - * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | - * @link http://kcfinder.sunhater.com |
|
13 | - */ |
|
4 | + * |
|
5 | + * @desc Path helper class |
|
6 | + * @package KCFinder |
|
7 | + * @version 2.54 |
|
8 | + * @author Pavel Tzonkov <[email protected]> |
|
9 | + * @copyright 2010-2014 KCFinder Project |
|
10 | + * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | + * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | + * @link http://kcfinder.sunhater.com |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | class path { |
16 | 16 | |
17 | - /** Get the absolute URL path of the given one. Returns FALSE if the URL |
|
18 | - * is not valid or the current directory cannot be resolved (getcwd()) |
|
19 | - * @param string $path |
|
20 | - * @return string */ |
|
17 | + /** Get the absolute URL path of the given one. Returns FALSE if the URL |
|
18 | + * is not valid or the current directory cannot be resolved (getcwd()) |
|
19 | + * @param string $path |
|
20 | + * @return string */ |
|
21 | 21 | |
22 | 22 | static function rel2abs_url($path) { |
23 | 23 | if (substr($path, 0, 1) == "/") return $path; |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | return $return; |
40 | 40 | } |
41 | 41 | |
42 | - /** Resolve full filesystem path of given URL. Returns FALSE if the URL |
|
43 | - * cannot be resolved |
|
44 | - * @param string $url |
|
45 | - * @return string */ |
|
42 | + /** Resolve full filesystem path of given URL. Returns FALSE if the URL |
|
43 | + * cannot be resolved |
|
44 | + * @param string $url |
|
45 | + * @return string */ |
|
46 | 46 | |
47 | 47 | static function url2fullPath($url) { |
48 | 48 | $url = self::normalize($url); |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
87 | - /** Normalize the given path. On Windows servers backslash will be replaced |
|
88 | - * with slash. Remobes unnecessary doble slashes and double dots. Removes |
|
89 | - * last slash if it exists. Examples: |
|
90 | - * path::normalize("C:\\any\\path\\") returns "C:/any/path" |
|
91 | - * path::normalize("/your/path/..//home/") returns "/your/home" |
|
92 | - * @param string $path |
|
93 | - * @return string */ |
|
87 | + /** Normalize the given path. On Windows servers backslash will be replaced |
|
88 | + * with slash. Remobes unnecessary doble slashes and double dots. Removes |
|
89 | + * last slash if it exists. Examples: |
|
90 | + * path::normalize("C:\\any\\path\\") returns "C:/any/path" |
|
91 | + * path::normalize("/your/path/..//home/") returns "/your/home" |
|
92 | + * @param string $path |
|
93 | + * @return string */ |
|
94 | 94 | |
95 | 95 | static function normalize($path) { |
96 | 96 | if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") { |
@@ -114,9 +114,9 @@ discard block |
||
114 | 114 | return $path; |
115 | 115 | } |
116 | 116 | |
117 | - /** Encode URL Path |
|
118 | - * @param string $path |
|
119 | - * @return string */ |
|
117 | + /** Encode URL Path |
|
118 | + * @param string $path |
|
119 | + * @return string */ |
|
120 | 120 | |
121 | 121 | static function urlPathEncode($path) { |
122 | 122 | $path = self::normalize($path); |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | return $encoded; |
128 | 128 | } |
129 | 129 | |
130 | - /** Decode URL Path |
|
131 | - * @param string $path |
|
132 | - * @return string */ |
|
130 | + /** Decode URL Path |
|
131 | + * @param string $path |
|
132 | + * @return string */ |
|
133 | 133 | |
134 | 134 | static function urlPathDecode($path) { |
135 | 135 | $path = self::normalize($path); |
@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class path { |
|
15 | +class path{ |
|
16 | 16 | |
17 | 17 | /** Get the absolute URL path of the given one. Returns FALSE if the URL |
18 | 18 | * is not valid or the current directory cannot be resolved (getcwd()) |
19 | 19 | * @param string $path |
20 | 20 | * @return string */ |
21 | 21 | |
22 | - static function rel2abs_url($path) { |
|
22 | + static function rel2abs_url($path){ |
|
23 | 23 | if (substr($path, 0, 1) == "/") return $path; |
24 | 24 | $dir = @getcwd(); |
25 | 25 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | if (substr($dir, 0, strlen($doc_root)) != $doc_root) |
33 | 33 | return false; |
34 | 34 | |
35 | - $return = self::normalize(substr($dir, strlen($doc_root)) . "/$path"); |
|
35 | + $return = self::normalize(substr($dir, strlen($doc_root))."/$path"); |
|
36 | 36 | if (substr($return, 0, 1) !== "/") |
37 | 37 | $return = "/$return"; |
38 | 38 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param string $url |
45 | 45 | * @return string */ |
46 | 46 | |
47 | - static function url2fullPath($url) { |
|
47 | + static function url2fullPath($url){ |
|
48 | 48 | $url = self::normalize($url); |
49 | 49 | |
50 | 50 | $uri = isset($_SERVER['SCRIPT_NAME']) |
@@ -56,18 +56,18 @@ discard block |
||
56 | 56 | |
57 | 57 | if (substr($url, 0, 1) !== "/") { |
58 | 58 | if ($uri === false) return false; |
59 | - $url = dirname($uri) . "/$url"; |
|
59 | + $url = dirname($uri)."/$url"; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | if (isset($_SERVER['DOCUMENT_ROOT'])) { |
63 | - return self::normalize($_SERVER['DOCUMENT_ROOT'] . "/$url"); |
|
63 | + return self::normalize($_SERVER['DOCUMENT_ROOT']."/$url"); |
|
64 | 64 | |
65 | 65 | } else { |
66 | 66 | if ($uri === false) return false; |
67 | 67 | |
68 | 68 | if (isset($_SERVER['SCRIPT_FILENAME'])) { |
69 | 69 | $scr_filename = self::normalize($_SERVER['SCRIPT_FILENAME']); |
70 | - return self::normalize(substr($scr_filename, 0, -strlen($uri)) . "/$url"); |
|
70 | + return self::normalize(substr($scr_filename, 0, -strlen($uri))."/$url"); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | $count = count(explode('/', $uri)) - 1; |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | return false; |
81 | 81 | $rdir = getcwd(); |
82 | 82 | chdir($dir); |
83 | - return ($rdir !== false) ? self::normalize($rdir . "/$url") : false; |
|
83 | + return ($rdir !== false) ? self::normalize($rdir."/$url") : false; |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | * @param string $path |
93 | 93 | * @return string */ |
94 | 94 | |
95 | - static function normalize($path) { |
|
95 | + static function normalize($path){ |
|
96 | 96 | if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") { |
97 | 97 | $path = preg_replace('/([^\\\])\\\([^\\\])/', "$1/$2", $path); |
98 | 98 | if (substr($path, -1) == "\\") $path = substr($path, 0, -1); |
99 | - if (substr($path, 0, 1) == "\\") $path = "/" . substr($path, 1); |
|
99 | + if (substr($path, 0, 1) == "\\") $path = "/".substr($path, 1); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | $path = preg_replace('/\/+/s', "/", $path); |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | * @param string $path |
119 | 119 | * @return string */ |
120 | 120 | |
121 | - static function urlPathEncode($path) { |
|
121 | + static function urlPathEncode($path){ |
|
122 | 122 | $path = self::normalize($path); |
123 | 123 | $encoded = ""; |
124 | 124 | foreach (explode("/", $path) as $dir) |
125 | - $encoded .= rawurlencode($dir) . "/"; |
|
125 | + $encoded .= rawurlencode($dir)."/"; |
|
126 | 126 | $encoded = substr($encoded, 0, -1); |
127 | 127 | return $encoded; |
128 | 128 | } |
@@ -131,11 +131,11 @@ discard block |
||
131 | 131 | * @param string $path |
132 | 132 | * @return string */ |
133 | 133 | |
134 | - static function urlPathDecode($path) { |
|
134 | + static function urlPathDecode($path){ |
|
135 | 135 | $path = self::normalize($path); |
136 | 136 | $decoded = ""; |
137 | 137 | foreach (explode("/", $path) as $dir) |
138 | - $decoded .= rawurldecode($dir) . "/"; |
|
138 | + $decoded .= rawurldecode($dir)."/"; |
|
139 | 139 | $decoded = substr($decoded, 0, -1); |
140 | 140 | return $decoded; |
141 | 141 | } |
@@ -12,29 +12,36 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class path { |
|
15 | +class path |
|
16 | +{ |
|
16 | 17 | |
17 | 18 | /** Get the absolute URL path of the given one. Returns FALSE if the URL |
18 | 19 | * is not valid or the current directory cannot be resolved (getcwd()) |
19 | 20 | * @param string $path |
20 | 21 | * @return string */ |
21 | 22 | |
22 | - static function rel2abs_url($path) { |
|
23 | - if (substr($path, 0, 1) == "/") return $path; |
|
23 | + static function rel2abs_url($path) |
|
24 | + { |
|
25 | + if (substr($path, 0, 1) == "/") { |
|
26 | + return $path; |
|
27 | + } |
|
24 | 28 | $dir = @getcwd(); |
25 | 29 | |
26 | - if (!isset($_SERVER['DOCUMENT_ROOT']) || ($dir === false)) |
|
27 | - return false; |
|
30 | + if (!isset($_SERVER['DOCUMENT_ROOT']) || ($dir === false)) { |
|
31 | + return false; |
|
32 | + } |
|
28 | 33 | |
29 | 34 | $dir = self::normalize($dir); |
30 | 35 | $doc_root = self::normalize($_SERVER['DOCUMENT_ROOT']); |
31 | 36 | |
32 | - if (substr($dir, 0, strlen($doc_root)) != $doc_root) |
|
33 | - return false; |
|
37 | + if (substr($dir, 0, strlen($doc_root)) != $doc_root) { |
|
38 | + return false; |
|
39 | + } |
|
34 | 40 | |
35 | 41 | $return = self::normalize(substr($dir, strlen($doc_root)) . "/$path"); |
36 | - if (substr($return, 0, 1) !== "/") |
|
37 | - $return = "/$return"; |
|
42 | + if (substr($return, 0, 1) !== "/") { |
|
43 | + $return = "/$return"; |
|
44 | + } |
|
38 | 45 | |
39 | 46 | return $return; |
40 | 47 | } |
@@ -44,7 +51,8 @@ discard block |
||
44 | 51 | * @param string $url |
45 | 52 | * @return string */ |
46 | 53 | |
47 | - static function url2fullPath($url) { |
|
54 | + static function url2fullPath($url) |
|
55 | + { |
|
48 | 56 | $url = self::normalize($url); |
49 | 57 | |
50 | 58 | $uri = isset($_SERVER['SCRIPT_NAME']) |
@@ -55,7 +63,9 @@ discard block |
||
55 | 63 | $uri = self::normalize($uri); |
56 | 64 | |
57 | 65 | if (substr($url, 0, 1) !== "/") { |
58 | - if ($uri === false) return false; |
|
66 | + if ($uri === false) { |
|
67 | + return false; |
|
68 | + } |
|
59 | 69 | $url = dirname($uri) . "/$url"; |
60 | 70 | } |
61 | 71 | |
@@ -63,7 +73,9 @@ discard block |
||
63 | 73 | return self::normalize($_SERVER['DOCUMENT_ROOT'] . "/$url"); |
64 | 74 | |
65 | 75 | } else { |
66 | - if ($uri === false) return false; |
|
76 | + if ($uri === false) { |
|
77 | + return false; |
|
78 | + } |
|
67 | 79 | |
68 | 80 | if (isset($_SERVER['SCRIPT_FILENAME'])) { |
69 | 81 | $scr_filename = self::normalize($_SERVER['SCRIPT_FILENAME']); |
@@ -71,13 +83,15 @@ discard block |
||
71 | 83 | } |
72 | 84 | |
73 | 85 | $count = count(explode('/', $uri)) - 1; |
74 | - for ($i = 0, $chdir = ""; $i < $count; $i++) |
|
75 | - $chdir .= "../"; |
|
86 | + for ($i = 0, $chdir = ""; $i < $count; $i++) { |
|
87 | + $chdir .= "../"; |
|
88 | + } |
|
76 | 89 | $chdir = self::normalize($chdir); |
77 | 90 | |
78 | 91 | $dir = getcwd(); |
79 | - if (($dir === false) || !@chdir($chdir)) |
|
80 | - return false; |
|
92 | + if (($dir === false) || !@chdir($chdir)) { |
|
93 | + return false; |
|
94 | + } |
|
81 | 95 | $rdir = getcwd(); |
82 | 96 | chdir($dir); |
83 | 97 | return ($rdir !== false) ? self::normalize($rdir . "/$url") : false; |
@@ -92,22 +106,29 @@ discard block |
||
92 | 106 | * @param string $path |
93 | 107 | * @return string */ |
94 | 108 | |
95 | - static function normalize($path) { |
|
109 | + static function normalize($path) |
|
110 | + { |
|
96 | 111 | if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") { |
97 | 112 | $path = preg_replace('/([^\\\])\\\([^\\\])/', "$1/$2", $path); |
98 | - if (substr($path, -1) == "\\") $path = substr($path, 0, -1); |
|
99 | - if (substr($path, 0, 1) == "\\") $path = "/" . substr($path, 1); |
|
113 | + if (substr($path, -1) == "\\") { |
|
114 | + $path = substr($path, 0, -1); |
|
115 | + } |
|
116 | + if (substr($path, 0, 1) == "\\") { |
|
117 | + $path = "/" . substr($path, 1); |
|
118 | + } |
|
100 | 119 | } |
101 | 120 | |
102 | 121 | $path = preg_replace('/\/+/s', "/", $path); |
103 | 122 | |
104 | 123 | $path = "/$path"; |
105 | - if (substr($path, -1) != "/") |
|
106 | - $path .= "/"; |
|
124 | + if (substr($path, -1) != "/") { |
|
125 | + $path .= "/"; |
|
126 | + } |
|
107 | 127 | |
108 | 128 | $expr = '/\/([^\/]{1}|[^\.\/]{2}|[^\/]{3,})\/\.\.\//s'; |
109 | - while (preg_match($expr, $path)) |
|
110 | - $path = preg_replace($expr, "/", $path); |
|
129 | + while (preg_match($expr, $path)) { |
|
130 | + $path = preg_replace($expr, "/", $path); |
|
131 | + } |
|
111 | 132 | |
112 | 133 | $path = substr($path, 0, -1); |
113 | 134 | $path = substr($path, 1); |
@@ -118,11 +139,13 @@ discard block |
||
118 | 139 | * @param string $path |
119 | 140 | * @return string */ |
120 | 141 | |
121 | - static function urlPathEncode($path) { |
|
142 | + static function urlPathEncode($path) |
|
143 | + { |
|
122 | 144 | $path = self::normalize($path); |
123 | 145 | $encoded = ""; |
124 | - foreach (explode("/", $path) as $dir) |
|
125 | - $encoded .= rawurlencode($dir) . "/"; |
|
146 | + foreach (explode("/", $path) as $dir) { |
|
147 | + $encoded .= rawurlencode($dir) . "/"; |
|
148 | + } |
|
126 | 149 | $encoded = substr($encoded, 0, -1); |
127 | 150 | return $encoded; |
128 | 151 | } |
@@ -131,11 +154,13 @@ discard block |
||
131 | 154 | * @param string $path |
132 | 155 | * @return string */ |
133 | 156 | |
134 | - static function urlPathDecode($path) { |
|
157 | + static function urlPathDecode($path) |
|
158 | + { |
|
135 | 159 | $path = self::normalize($path); |
136 | 160 | $decoded = ""; |
137 | - foreach (explode("/", $path) as $dir) |
|
138 | - $decoded .= rawurldecode($dir) . "/"; |
|
161 | + foreach (explode("/", $path) as $dir) { |
|
162 | + $decoded .= rawurldecode($dir) . "/"; |
|
163 | + } |
|
139 | 164 | $decoded = substr($decoded, 0, -1); |
140 | 165 | return $decoded; |
141 | 166 | } |
@@ -1,29 +1,29 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** This file is part of KCFinder project |
4 | - * |
|
5 | - * @desc HTTP cache helper class |
|
6 | - * @package KCFinder |
|
7 | - * @version 2.54 |
|
8 | - * @author Pavel Tzonkov <[email protected]> |
|
9 | - * @copyright 2010-2014 KCFinder Project |
|
10 | - * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | - * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | - * @link http://kcfinder.sunhater.com |
|
13 | - */ |
|
4 | + * |
|
5 | + * @desc HTTP cache helper class |
|
6 | + * @package KCFinder |
|
7 | + * @version 2.54 |
|
8 | + * @author Pavel Tzonkov <[email protected]> |
|
9 | + * @copyright 2010-2014 KCFinder Project |
|
10 | + * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | + * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | + * @link http://kcfinder.sunhater.com |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | class httpCache { |
16 | 16 | const DEFAULT_TYPE = "text/html"; |
17 | 17 | const DEFAULT_EXPIRE = 604800; // in seconds |
18 | 18 | |
19 | - /** Cache a file. The $type parameter might define the MIME type of the file |
|
20 | - * or path to magic file to autodetect the MIME type. If you skip $type |
|
21 | - * parameter the method will try with the default magic file. Autodetection |
|
22 | - * of MIME type requires Fileinfo PHP extension used in file::getMimeType() |
|
23 | - * @param string $file |
|
24 | - * @param string $type |
|
25 | - * @param integer $expire |
|
26 | - * @param array $headers */ |
|
19 | + /** Cache a file. The $type parameter might define the MIME type of the file |
|
20 | + * or path to magic file to autodetect the MIME type. If you skip $type |
|
21 | + * parameter the method will try with the default magic file. Autodetection |
|
22 | + * of MIME type requires Fileinfo PHP extension used in file::getMimeType() |
|
23 | + * @param string $file |
|
24 | + * @param string $type |
|
25 | + * @param integer $expire |
|
26 | + * @param array $headers */ |
|
27 | 27 | |
28 | 28 | static function file($file, $type=null, $expire=null, array $headers=null) { |
29 | 29 | $mtime = @filemtime($file); |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | self::content(@file_get_contents($file), $mtime, $type, $expire, $headers, false); |
40 | 40 | } |
41 | 41 | |
42 | - /** Cache the given $content with $mtime modification time. |
|
43 | - * @param binary $content |
|
44 | - * @param integer $mtime |
|
45 | - * @param string $type |
|
46 | - * @param integer $expire |
|
47 | - * @param array $headers |
|
48 | - * @param bool $checkMTime */ |
|
42 | + /** Cache the given $content with $mtime modification time. |
|
43 | + * @param binary $content |
|
44 | + * @param integer $mtime |
|
45 | + * @param string $type |
|
46 | + * @param integer $expire |
|
47 | + * @param array $headers |
|
48 | + * @param bool $checkMTime */ |
|
49 | 49 | |
50 | 50 | static function content($content, $mtime, $type=null, $expire=null, array $headers=null, $checkMTime=true) { |
51 | 51 | if ($checkMTime) self::checkMTime($mtime); |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | echo $content; |
63 | 63 | } |
64 | 64 | |
65 | - /** Check if given modification time is newer than client-side one. If not, |
|
66 | - * the method will tell the client to get the content from its own cache. |
|
67 | - * Afterwards the script process will be terminated. This feature requires |
|
68 | - * the PHP to be configured as Apache module. |
|
69 | - * @param integer $mtime */ |
|
65 | + /** Check if given modification time is newer than client-side one. If not, |
|
66 | + * the method will tell the client to get the content from its own cache. |
|
67 | + * Afterwards the script process will be terminated. This feature requires |
|
68 | + * the PHP to be configured as Apache module. |
|
69 | + * @param integer $mtime */ |
|
70 | 70 | |
71 | 71 | static function checkMTime($mtime, $sendHeaders=null) { |
72 | 72 | header("Last-Modified: " . gmdate("D, d M Y H:i:s", $mtime) . " GMT"); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class httpCache { |
|
15 | +class httpCache{ |
|
16 | 16 | const DEFAULT_TYPE = "text/html"; |
17 | 17 | const DEFAULT_EXPIRE = 604800; // in seconds |
18 | 18 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param integer $expire |
26 | 26 | * @param array $headers */ |
27 | 27 | |
28 | - static function file($file, $type=null, $expire=null, array $headers=null) { |
|
28 | + static function file($file, $type = null, $expire = null, array $headers = null){ |
|
29 | 29 | $mtime = @filemtime($file); |
30 | 30 | if ($mtime !== false) self::checkMTime($mtime); |
31 | 31 | |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | * @param array $headers |
48 | 48 | * @param bool $checkMTime */ |
49 | 49 | |
50 | - static function content($content, $mtime, $type=null, $expire=null, array $headers=null, $checkMTime=true) { |
|
50 | + static function content($content, $mtime, $type = null, $expire = null, array $headers = null, $checkMTime = true){ |
|
51 | 51 | if ($checkMTime) self::checkMTime($mtime); |
52 | 52 | if ($type === null) $type = self::DEFAULT_TYPE; |
53 | 53 | if ($expire === null) $expire = self::DEFAULT_EXPIRE; |
54 | 54 | $size = strlen($content); |
55 | - $expires = gmdate("D, d M Y H:i:s", time() + $expire) . " GMT"; |
|
55 | + $expires = gmdate("D, d M Y H:i:s", time() + $expire)." GMT"; |
|
56 | 56 | header("Content-Type: $type"); |
57 | 57 | header("Expires: $expires"); |
58 | 58 | header("Cache-Control: max-age=$expire"); |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * the PHP to be configured as Apache module. |
69 | 69 | * @param integer $mtime */ |
70 | 70 | |
71 | - static function checkMTime($mtime, $sendHeaders=null) { |
|
72 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s", $mtime) . " GMT"); |
|
71 | + static function checkMTime($mtime, $sendHeaders = null){ |
|
72 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s", $mtime)." GMT"); |
|
73 | 73 | |
74 | 74 | $headers = function_exists("getallheaders") |
75 | 75 | ? getallheaders() |
@@ -12,7 +12,8 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class httpCache { |
|
15 | +class httpCache |
|
16 | +{ |
|
16 | 17 | const DEFAULT_TYPE = "text/html"; |
17 | 18 | const DEFAULT_EXPIRE = 604800; // in seconds |
18 | 19 | |
@@ -25,15 +26,20 @@ discard block |
||
25 | 26 | * @param integer $expire |
26 | 27 | * @param array $headers */ |
27 | 28 | |
28 | - static function file($file, $type=null, $expire=null, array $headers=null) { |
|
29 | + static function file($file, $type=null, $expire=null, array $headers=null) |
|
30 | + { |
|
29 | 31 | $mtime = @filemtime($file); |
30 | - if ($mtime !== false) self::checkMTime($mtime); |
|
32 | + if ($mtime !== false) { |
|
33 | + self::checkMTime($mtime); |
|
34 | + } |
|
31 | 35 | |
32 | 36 | if ($type === null) { |
33 | 37 | $magic = ((substr($type, 0, 1) == "/") || preg_match('/^[a-z]\:/i', $type)) |
34 | 38 | ? $type : null; |
35 | 39 | $type = file::getMimeType($file, $magic); |
36 | - if (!$type) $type = null; |
|
40 | + if (!$type) { |
|
41 | + $type = null; |
|
42 | + } |
|
37 | 43 | } |
38 | 44 | |
39 | 45 | self::content(@file_get_contents($file), $mtime, $type, $expire, $headers, false); |
@@ -47,10 +53,17 @@ discard block |
||
47 | 53 | * @param array $headers |
48 | 54 | * @param bool $checkMTime */ |
49 | 55 | |
50 | - static function content($content, $mtime, $type=null, $expire=null, array $headers=null, $checkMTime=true) { |
|
51 | - if ($checkMTime) self::checkMTime($mtime); |
|
52 | - if ($type === null) $type = self::DEFAULT_TYPE; |
|
53 | - if ($expire === null) $expire = self::DEFAULT_EXPIRE; |
|
56 | + static function content($content, $mtime, $type=null, $expire=null, array $headers=null, $checkMTime=true) |
|
57 | + { |
|
58 | + if ($checkMTime) { |
|
59 | + self::checkMTime($mtime); |
|
60 | + } |
|
61 | + if ($type === null) { |
|
62 | + $type = self::DEFAULT_TYPE; |
|
63 | + } |
|
64 | + if ($expire === null) { |
|
65 | + $expire = self::DEFAULT_EXPIRE; |
|
66 | + } |
|
54 | 67 | $size = strlen($content); |
55 | 68 | $expires = gmdate("D, d M Y H:i:s", time() + $expire) . " GMT"; |
56 | 69 | header("Content-Type: $type"); |
@@ -58,7 +71,9 @@ discard block |
||
58 | 71 | header("Cache-Control: max-age=$expire"); |
59 | 72 | header("Pragma: !invalid"); |
60 | 73 | header("Content-Length: $size"); |
61 | - if ($headers !== null) foreach ($headers as $header) header($header); |
|
74 | + if ($headers !== null) { |
|
75 | + foreach ($headers as $header) header($header); |
|
76 | + } |
|
62 | 77 | echo $content; |
63 | 78 | } |
64 | 79 | |
@@ -68,7 +83,8 @@ discard block |
||
68 | 83 | * the PHP to be configured as Apache module. |
69 | 84 | * @param integer $mtime */ |
70 | 85 | |
71 | - static function checkMTime($mtime, $sendHeaders=null) { |
|
86 | + static function checkMTime($mtime, $sendHeaders=null) |
|
87 | + { |
|
72 | 88 | header("Last-Modified: " . gmdate("D, d M Y H:i:s", $mtime) . " GMT"); |
73 | 89 | |
74 | 90 | $headers = function_exists("getallheaders") |
@@ -82,11 +98,12 @@ discard block |
||
82 | 98 | $client_mtime = @strtotime($client_mtime[0]); |
83 | 99 | if ($client_mtime >= $mtime) { |
84 | 100 | header('HTTP/1.1 304 Not Modified'); |
85 | - if (is_array($sendHeaders) && count($sendHeaders)) |
|
86 | - foreach ($sendHeaders as $header) |
|
101 | + if (is_array($sendHeaders) && count($sendHeaders)) { |
|
102 | + foreach ($sendHeaders as $header) |
|
87 | 103 | header($header); |
88 | - elseif ($sendHeaders !== null) |
|
89 | - header($sendHeaders); |
|
104 | + } elseif ($sendHeaders !== null) { |
|
105 | + header($sendHeaders); |
|
106 | + } |
|
90 | 107 | |
91 | 108 | |
92 | 109 | die; |
@@ -1,30 +1,30 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /** This file is part of KCFinder project |
4 | - * |
|
5 | - * @desc Text processing helper class |
|
6 | - * @package KCFinder |
|
7 | - * @version 2.54 |
|
8 | - * @author Pavel Tzonkov <[email protected]> |
|
9 | - * @copyright 2010-2014 KCFinder Project |
|
10 | - * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | - * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | - * @link http://kcfinder.sunhater.com |
|
13 | - */ |
|
4 | + * |
|
5 | + * @desc Text processing helper class |
|
6 | + * @package KCFinder |
|
7 | + * @version 2.54 |
|
8 | + * @author Pavel Tzonkov <[email protected]> |
|
9 | + * @copyright 2010-2014 KCFinder Project |
|
10 | + * @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2 |
|
11 | + * @license http://www.opensource.org/licenses/lgpl-2.1.php LGPLv2 |
|
12 | + * @link http://kcfinder.sunhater.com |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | class text { |
16 | 16 | |
17 | - /** Replace repeated white spaces to single space |
|
18 | - * @param string $string |
|
19 | - * @return string */ |
|
17 | + /** Replace repeated white spaces to single space |
|
18 | + * @param string $string |
|
19 | + * @return string */ |
|
20 | 20 | |
21 | 21 | static function clearWhitespaces($string) { |
22 | 22 | return trim(preg_replace('/\s+/s', " ", $string)); |
23 | 23 | } |
24 | 24 | |
25 | - /** Normalize the string for HTML attribute value |
|
26 | - * @param string $string |
|
27 | - * @return string */ |
|
25 | + /** Normalize the string for HTML attribute value |
|
26 | + * @param string $string |
|
27 | + * @return string */ |
|
28 | 28 | |
29 | 29 | static function htmlValue($string) { |
30 | 30 | return |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | $string)))); |
36 | 36 | } |
37 | 37 | |
38 | - /** Normalize the string for JavaScript string value |
|
39 | - * @param string $string |
|
40 | - * @return string */ |
|
38 | + /** Normalize the string for JavaScript string value |
|
39 | + * @param string $string |
|
40 | + * @return string */ |
|
41 | 41 | |
42 | 42 | static function jsValue($string) { |
43 | 43 | return |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | $string)))); |
49 | 49 | } |
50 | 50 | |
51 | - /** Normalize the string for XML tag content data |
|
52 | - * @param string $string |
|
53 | - * @param bool $cdata */ |
|
51 | + /** Normalize the string for XML tag content data |
|
52 | + * @param string $string |
|
53 | + * @param bool $cdata */ |
|
54 | 54 | |
55 | 55 | static function xmlData($string, $cdata=false) { |
56 | 56 | $string = str_replace("]]>", "]]]]><![CDATA[>", $string); |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | return $string; |
60 | 60 | } |
61 | 61 | |
62 | - /** Returns compressed content of given CSS code |
|
63 | - * @param string $code |
|
64 | - * @return string */ |
|
62 | + /** Returns compressed content of given CSS code |
|
63 | + * @param string $code |
|
64 | + * @return string */ |
|
65 | 65 | |
66 | 66 | static function compressCSS($code) { |
67 | 67 | $code = self::clearWhitespaces($code); |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class text { |
|
15 | +class text{ |
|
16 | 16 | |
17 | 17 | /** Replace repeated white spaces to single space |
18 | 18 | * @param string $string |
19 | 19 | * @return string */ |
20 | 20 | |
21 | - static function clearWhitespaces($string) { |
|
21 | + static function clearWhitespaces($string){ |
|
22 | 22 | return trim(preg_replace('/\s+/s', " ", $string)); |
23 | 23 | } |
24 | 24 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param string $string |
27 | 27 | * @return string */ |
28 | 28 | |
29 | - static function htmlValue($string) { |
|
29 | + static function htmlValue($string){ |
|
30 | 30 | return |
31 | 31 | str_replace('"', """, |
32 | 32 | str_replace("'", ''', |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param string $string |
40 | 40 | * @return string */ |
41 | 41 | |
42 | - static function jsValue($string) { |
|
42 | + static function jsValue($string){ |
|
43 | 43 | return |
44 | 44 | preg_replace('/\r?\n/', "\\n", |
45 | 45 | str_replace('"', "\\\"", |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @param string $string |
53 | 53 | * @param bool $cdata */ |
54 | 54 | |
55 | - static function xmlData($string, $cdata=false) { |
|
55 | + static function xmlData($string, $cdata = false){ |
|
56 | 56 | $string = str_replace("]]>", "]]]]><![CDATA[>", $string); |
57 | 57 | if (!$cdata) |
58 | 58 | $string = "<![CDATA[$string]]>"; |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @param string $code |
64 | 64 | * @return string */ |
65 | 65 | |
66 | - static function compressCSS($code) { |
|
66 | + static function compressCSS($code){ |
|
67 | 67 | $code = self::clearWhitespaces($code); |
68 | 68 | $code = preg_replace('/ ?\{ ?/', "{", $code); |
69 | 69 | $code = preg_replace('/ ?\} ?/', "}", $code); |
@@ -12,13 +12,15 @@ discard block |
||
12 | 12 | * @link http://kcfinder.sunhater.com |
13 | 13 | */ |
14 | 14 | |
15 | -class text { |
|
15 | +class text |
|
16 | +{ |
|
16 | 17 | |
17 | 18 | /** Replace repeated white spaces to single space |
18 | 19 | * @param string $string |
19 | 20 | * @return string */ |
20 | 21 | |
21 | - static function clearWhitespaces($string) { |
|
22 | + static function clearWhitespaces($string) |
|
23 | + { |
|
22 | 24 | return trim(preg_replace('/\s+/s', " ", $string)); |
23 | 25 | } |
24 | 26 | |
@@ -26,7 +28,8 @@ discard block |
||
26 | 28 | * @param string $string |
27 | 29 | * @return string */ |
28 | 30 | |
29 | - static function htmlValue($string) { |
|
31 | + static function htmlValue($string) |
|
32 | + { |
|
30 | 33 | return |
31 | 34 | str_replace('"', """, |
32 | 35 | str_replace("'", ''', |
@@ -39,7 +42,8 @@ discard block |
||
39 | 42 | * @param string $string |
40 | 43 | * @return string */ |
41 | 44 | |
42 | - static function jsValue($string) { |
|
45 | + static function jsValue($string) |
|
46 | + { |
|
43 | 47 | return |
44 | 48 | preg_replace('/\r?\n/', "\\n", |
45 | 49 | str_replace('"', "\\\"", |
@@ -52,10 +56,12 @@ discard block |
||
52 | 56 | * @param string $string |
53 | 57 | * @param bool $cdata */ |
54 | 58 | |
55 | - static function xmlData($string, $cdata=false) { |
|
59 | + static function xmlData($string, $cdata=false) |
|
60 | + { |
|
56 | 61 | $string = str_replace("]]>", "]]]]><![CDATA[>", $string); |
57 | - if (!$cdata) |
|
58 | - $string = "<![CDATA[$string]]>"; |
|
62 | + if (!$cdata) { |
|
63 | + $string = "<![CDATA[$string]]>"; |
|
64 | + } |
|
59 | 65 | return $string; |
60 | 66 | } |
61 | 67 | |
@@ -63,7 +69,8 @@ discard block |
||
63 | 69 | * @param string $code |
64 | 70 | * @return string */ |
65 | 71 | |
66 | - static function compressCSS($code) { |
|
72 | + static function compressCSS($code) |
|
73 | + { |
|
67 | 74 | $code = self::clearWhitespaces($code); |
68 | 75 | $code = preg_replace('/ ?\{ ?/', "{", $code); |
69 | 76 | $code = preg_replace('/ ?\} ?/', "}", $code); |