@@ -17,5 +17,5 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | function smarty_modifiercompiler_noprint() |
| 19 | 19 | { |
| 20 | - return "''"; |
|
| 20 | + return "''"; |
|
| 21 | 21 | } |
@@ -25,9 +25,9 @@ |
||
| 25 | 25 | |
| 26 | 26 | function smarty_modifiercompiler_strip($params) |
| 27 | 27 | { |
| 28 | - if (!isset($params[ 1 ])) { |
|
| 29 | - $params[ 1 ] = "' '"; |
|
| 30 | - } |
|
| 28 | + if (!isset($params[ 1 ])) { |
|
| 29 | + $params[ 1 ] = "' '"; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})"; |
|
| 32 | + return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})"; |
|
| 33 | 33 | } |
@@ -25,8 +25,8 @@ |
||
| 25 | 25 | |
| 26 | 26 | function smarty_modifiercompiler_strip($params) |
| 27 | 27 | { |
| 28 | - if (!isset($params[ 1 ])) { |
|
| 29 | - $params[ 1 ] = "' '"; |
|
| 28 | + if (!isset($params[1])) { |
|
| 29 | + $params[1] = "' '"; |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})"; |
@@ -24,198 +24,198 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | function smarty_function_fetch($params, $template) |
| 26 | 26 | { |
| 27 | - if (empty($params[ 'file' ])) { |
|
| 28 | - trigger_error("[plugin] fetch parameter 'file' cannot be empty", E_USER_NOTICE); |
|
| 29 | - |
|
| 30 | - return; |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - // strip file protocol |
|
| 34 | - if (stripos($params[ 'file' ], 'file://') === 0) { |
|
| 35 | - $params[ 'file' ] = substr($params[ 'file' ], 7); |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - $protocol = strpos($params[ 'file' ], '://'); |
|
| 39 | - if ($protocol !== false) { |
|
| 40 | - $protocol = strtolower(substr($params[ 'file' ], 0, $protocol)); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - if (isset($template->smarty->security_policy)) { |
|
| 44 | - if ($protocol) { |
|
| 45 | - // remote resource (or php stream, …) |
|
| 46 | - if (!$template->smarty->security_policy->isTrustedUri($params[ 'file' ])) { |
|
| 47 | - return; |
|
| 48 | - } |
|
| 49 | - } else { |
|
| 50 | - // local file |
|
| 51 | - if (!$template->smarty->security_policy->isTrustedResourceDir($params[ 'file' ])) { |
|
| 52 | - return; |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - $content = ''; |
|
| 58 | - if ($protocol == 'http') { |
|
| 59 | - // http fetch |
|
| 60 | - if ($uri_parts = parse_url($params[ 'file' ])) { |
|
| 61 | - // set defaults |
|
| 62 | - $host = $server_name = $uri_parts[ 'host' ]; |
|
| 63 | - $timeout = 30; |
|
| 64 | - $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; |
|
| 65 | - $agent = "Smarty Template Engine " . Smarty::SMARTY_VERSION; |
|
| 66 | - $referer = ""; |
|
| 67 | - $uri = !empty($uri_parts[ 'path' ]) ? $uri_parts[ 'path' ] : '/'; |
|
| 68 | - $uri .= !empty($uri_parts[ 'query' ]) ? '?' . $uri_parts[ 'query' ] : ''; |
|
| 69 | - $_is_proxy = false; |
|
| 70 | - if (empty($uri_parts[ 'port' ])) { |
|
| 71 | - $port = 80; |
|
| 72 | - } else { |
|
| 73 | - $port = $uri_parts[ 'port' ]; |
|
| 74 | - } |
|
| 75 | - if (!empty($uri_parts[ 'user' ])) { |
|
| 76 | - $user = $uri_parts[ 'user' ]; |
|
| 77 | - } |
|
| 78 | - if (!empty($uri_parts[ 'pass' ])) { |
|
| 79 | - $pass = $uri_parts[ 'pass' ]; |
|
| 80 | - } |
|
| 81 | - // loop through parameters, setup headers |
|
| 82 | - foreach ($params as $param_key => $param_value) { |
|
| 83 | - switch ($param_key) { |
|
| 84 | - case "file": |
|
| 85 | - case "assign": |
|
| 86 | - case "assign_headers": |
|
| 87 | - break; |
|
| 88 | - case "user": |
|
| 89 | - if (!empty($param_value)) { |
|
| 90 | - $user = $param_value; |
|
| 91 | - } |
|
| 92 | - break; |
|
| 93 | - case "pass": |
|
| 94 | - if (!empty($param_value)) { |
|
| 95 | - $pass = $param_value; |
|
| 96 | - } |
|
| 97 | - break; |
|
| 98 | - case "accept": |
|
| 99 | - if (!empty($param_value)) { |
|
| 100 | - $accept = $param_value; |
|
| 101 | - } |
|
| 102 | - break; |
|
| 103 | - case "header": |
|
| 104 | - if (!empty($param_value)) { |
|
| 105 | - if (!preg_match('![\w\d-]+: .+!', $param_value)) { |
|
| 106 | - trigger_error("[plugin] invalid header format '" . $param_value . "'", E_USER_NOTICE); |
|
| 107 | - |
|
| 108 | - return; |
|
| 109 | - } else { |
|
| 110 | - $extra_headers[] = $param_value; |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - break; |
|
| 114 | - case "proxy_host": |
|
| 115 | - if (!empty($param_value)) { |
|
| 116 | - $proxy_host = $param_value; |
|
| 117 | - } |
|
| 118 | - break; |
|
| 119 | - case "proxy_port": |
|
| 120 | - if (!preg_match('!\D!', $param_value)) { |
|
| 121 | - $proxy_port = (int) $param_value; |
|
| 122 | - } else { |
|
| 123 | - trigger_error("[plugin] invalid value for attribute '" . $param_key . "'", E_USER_NOTICE); |
|
| 124 | - |
|
| 125 | - return; |
|
| 126 | - } |
|
| 127 | - break; |
|
| 128 | - case "agent": |
|
| 129 | - if (!empty($param_value)) { |
|
| 130 | - $agent = $param_value; |
|
| 131 | - } |
|
| 132 | - break; |
|
| 133 | - case "referer": |
|
| 134 | - if (!empty($param_value)) { |
|
| 135 | - $referer = $param_value; |
|
| 136 | - } |
|
| 137 | - break; |
|
| 138 | - case "timeout": |
|
| 139 | - if (!preg_match('!\D!', $param_value)) { |
|
| 140 | - $timeout = (int) $param_value; |
|
| 141 | - } else { |
|
| 142 | - trigger_error("[plugin] invalid value for attribute '" . $param_key . "'", E_USER_NOTICE); |
|
| 143 | - |
|
| 144 | - return; |
|
| 145 | - } |
|
| 146 | - break; |
|
| 147 | - default: |
|
| 148 | - trigger_error("[plugin] unrecognized attribute '" . $param_key . "'", E_USER_NOTICE); |
|
| 149 | - |
|
| 150 | - return; |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - if (!empty($proxy_host) && !empty($proxy_port)) { |
|
| 154 | - $_is_proxy = true; |
|
| 155 | - $fp = fsockopen($proxy_host, $proxy_port, $errno, $errstr, $timeout); |
|
| 156 | - } else { |
|
| 157 | - $fp = fsockopen($server_name, $port, $errno, $errstr, $timeout); |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - if (!$fp) { |
|
| 161 | - trigger_error("[plugin] unable to fetch: $errstr ($errno)", E_USER_NOTICE); |
|
| 162 | - |
|
| 163 | - return; |
|
| 164 | - } else { |
|
| 165 | - if ($_is_proxy) { |
|
| 166 | - fputs($fp, 'GET ' . $params[ 'file' ] . " HTTP/1.0\r\n"); |
|
| 167 | - } else { |
|
| 168 | - fputs($fp, "GET $uri HTTP/1.0\r\n"); |
|
| 169 | - } |
|
| 170 | - if (!empty($host)) { |
|
| 171 | - fputs($fp, "Host: $host\r\n"); |
|
| 172 | - } |
|
| 173 | - if (!empty($accept)) { |
|
| 174 | - fputs($fp, "Accept: $accept\r\n"); |
|
| 175 | - } |
|
| 176 | - if (!empty($agent)) { |
|
| 177 | - fputs($fp, "User-Agent: $agent\r\n"); |
|
| 178 | - } |
|
| 179 | - if (!empty($referer)) { |
|
| 180 | - fputs($fp, "Referer: $referer\r\n"); |
|
| 181 | - } |
|
| 182 | - if (isset($extra_headers) && is_array($extra_headers)) { |
|
| 183 | - foreach ($extra_headers as $curr_header) { |
|
| 184 | - fputs($fp, $curr_header . "\r\n"); |
|
| 185 | - } |
|
| 186 | - } |
|
| 187 | - if (!empty($user) && !empty($pass)) { |
|
| 188 | - fputs($fp, "Authorization: BASIC " . base64_encode("$user:$pass") . "\r\n"); |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - fputs($fp, "\r\n"); |
|
| 192 | - while (!feof($fp)) { |
|
| 193 | - $content .= fgets($fp, 4096); |
|
| 194 | - } |
|
| 195 | - fclose($fp); |
|
| 196 | - $csplit = preg_split("!\r\n\r\n!", $content, 2); |
|
| 197 | - |
|
| 198 | - $content = $csplit[ 1 ]; |
|
| 199 | - |
|
| 200 | - if (!empty($params[ 'assign_headers' ])) { |
|
| 201 | - $template->assign($params[ 'assign_headers' ], preg_split("!\r\n!", $csplit[ 0 ])); |
|
| 202 | - } |
|
| 203 | - } |
|
| 204 | - } else { |
|
| 205 | - trigger_error("[plugin fetch] unable to parse URL, check syntax", E_USER_NOTICE); |
|
| 206 | - |
|
| 207 | - return; |
|
| 208 | - } |
|
| 209 | - } else { |
|
| 210 | - $content = @file_get_contents($params[ 'file' ]); |
|
| 211 | - if ($content === false) { |
|
| 212 | - throw new SmartyException("{fetch} cannot read resource '" . $params[ 'file' ] . "'"); |
|
| 213 | - } |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - if (!empty($params[ 'assign' ])) { |
|
| 217 | - $template->assign($params[ 'assign' ], $content); |
|
| 218 | - } else { |
|
| 219 | - return $content; |
|
| 220 | - } |
|
| 27 | + if (empty($params[ 'file' ])) { |
|
| 28 | + trigger_error("[plugin] fetch parameter 'file' cannot be empty", E_USER_NOTICE); |
|
| 29 | + |
|
| 30 | + return; |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + // strip file protocol |
|
| 34 | + if (stripos($params[ 'file' ], 'file://') === 0) { |
|
| 35 | + $params[ 'file' ] = substr($params[ 'file' ], 7); |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + $protocol = strpos($params[ 'file' ], '://'); |
|
| 39 | + if ($protocol !== false) { |
|
| 40 | + $protocol = strtolower(substr($params[ 'file' ], 0, $protocol)); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + if (isset($template->smarty->security_policy)) { |
|
| 44 | + if ($protocol) { |
|
| 45 | + // remote resource (or php stream, …) |
|
| 46 | + if (!$template->smarty->security_policy->isTrustedUri($params[ 'file' ])) { |
|
| 47 | + return; |
|
| 48 | + } |
|
| 49 | + } else { |
|
| 50 | + // local file |
|
| 51 | + if (!$template->smarty->security_policy->isTrustedResourceDir($params[ 'file' ])) { |
|
| 52 | + return; |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + $content = ''; |
|
| 58 | + if ($protocol == 'http') { |
|
| 59 | + // http fetch |
|
| 60 | + if ($uri_parts = parse_url($params[ 'file' ])) { |
|
| 61 | + // set defaults |
|
| 62 | + $host = $server_name = $uri_parts[ 'host' ]; |
|
| 63 | + $timeout = 30; |
|
| 64 | + $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; |
|
| 65 | + $agent = "Smarty Template Engine " . Smarty::SMARTY_VERSION; |
|
| 66 | + $referer = ""; |
|
| 67 | + $uri = !empty($uri_parts[ 'path' ]) ? $uri_parts[ 'path' ] : '/'; |
|
| 68 | + $uri .= !empty($uri_parts[ 'query' ]) ? '?' . $uri_parts[ 'query' ] : ''; |
|
| 69 | + $_is_proxy = false; |
|
| 70 | + if (empty($uri_parts[ 'port' ])) { |
|
| 71 | + $port = 80; |
|
| 72 | + } else { |
|
| 73 | + $port = $uri_parts[ 'port' ]; |
|
| 74 | + } |
|
| 75 | + if (!empty($uri_parts[ 'user' ])) { |
|
| 76 | + $user = $uri_parts[ 'user' ]; |
|
| 77 | + } |
|
| 78 | + if (!empty($uri_parts[ 'pass' ])) { |
|
| 79 | + $pass = $uri_parts[ 'pass' ]; |
|
| 80 | + } |
|
| 81 | + // loop through parameters, setup headers |
|
| 82 | + foreach ($params as $param_key => $param_value) { |
|
| 83 | + switch ($param_key) { |
|
| 84 | + case "file": |
|
| 85 | + case "assign": |
|
| 86 | + case "assign_headers": |
|
| 87 | + break; |
|
| 88 | + case "user": |
|
| 89 | + if (!empty($param_value)) { |
|
| 90 | + $user = $param_value; |
|
| 91 | + } |
|
| 92 | + break; |
|
| 93 | + case "pass": |
|
| 94 | + if (!empty($param_value)) { |
|
| 95 | + $pass = $param_value; |
|
| 96 | + } |
|
| 97 | + break; |
|
| 98 | + case "accept": |
|
| 99 | + if (!empty($param_value)) { |
|
| 100 | + $accept = $param_value; |
|
| 101 | + } |
|
| 102 | + break; |
|
| 103 | + case "header": |
|
| 104 | + if (!empty($param_value)) { |
|
| 105 | + if (!preg_match('![\w\d-]+: .+!', $param_value)) { |
|
| 106 | + trigger_error("[plugin] invalid header format '" . $param_value . "'", E_USER_NOTICE); |
|
| 107 | + |
|
| 108 | + return; |
|
| 109 | + } else { |
|
| 110 | + $extra_headers[] = $param_value; |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + break; |
|
| 114 | + case "proxy_host": |
|
| 115 | + if (!empty($param_value)) { |
|
| 116 | + $proxy_host = $param_value; |
|
| 117 | + } |
|
| 118 | + break; |
|
| 119 | + case "proxy_port": |
|
| 120 | + if (!preg_match('!\D!', $param_value)) { |
|
| 121 | + $proxy_port = (int) $param_value; |
|
| 122 | + } else { |
|
| 123 | + trigger_error("[plugin] invalid value for attribute '" . $param_key . "'", E_USER_NOTICE); |
|
| 124 | + |
|
| 125 | + return; |
|
| 126 | + } |
|
| 127 | + break; |
|
| 128 | + case "agent": |
|
| 129 | + if (!empty($param_value)) { |
|
| 130 | + $agent = $param_value; |
|
| 131 | + } |
|
| 132 | + break; |
|
| 133 | + case "referer": |
|
| 134 | + if (!empty($param_value)) { |
|
| 135 | + $referer = $param_value; |
|
| 136 | + } |
|
| 137 | + break; |
|
| 138 | + case "timeout": |
|
| 139 | + if (!preg_match('!\D!', $param_value)) { |
|
| 140 | + $timeout = (int) $param_value; |
|
| 141 | + } else { |
|
| 142 | + trigger_error("[plugin] invalid value for attribute '" . $param_key . "'", E_USER_NOTICE); |
|
| 143 | + |
|
| 144 | + return; |
|
| 145 | + } |
|
| 146 | + break; |
|
| 147 | + default: |
|
| 148 | + trigger_error("[plugin] unrecognized attribute '" . $param_key . "'", E_USER_NOTICE); |
|
| 149 | + |
|
| 150 | + return; |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + if (!empty($proxy_host) && !empty($proxy_port)) { |
|
| 154 | + $_is_proxy = true; |
|
| 155 | + $fp = fsockopen($proxy_host, $proxy_port, $errno, $errstr, $timeout); |
|
| 156 | + } else { |
|
| 157 | + $fp = fsockopen($server_name, $port, $errno, $errstr, $timeout); |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + if (!$fp) { |
|
| 161 | + trigger_error("[plugin] unable to fetch: $errstr ($errno)", E_USER_NOTICE); |
|
| 162 | + |
|
| 163 | + return; |
|
| 164 | + } else { |
|
| 165 | + if ($_is_proxy) { |
|
| 166 | + fputs($fp, 'GET ' . $params[ 'file' ] . " HTTP/1.0\r\n"); |
|
| 167 | + } else { |
|
| 168 | + fputs($fp, "GET $uri HTTP/1.0\r\n"); |
|
| 169 | + } |
|
| 170 | + if (!empty($host)) { |
|
| 171 | + fputs($fp, "Host: $host\r\n"); |
|
| 172 | + } |
|
| 173 | + if (!empty($accept)) { |
|
| 174 | + fputs($fp, "Accept: $accept\r\n"); |
|
| 175 | + } |
|
| 176 | + if (!empty($agent)) { |
|
| 177 | + fputs($fp, "User-Agent: $agent\r\n"); |
|
| 178 | + } |
|
| 179 | + if (!empty($referer)) { |
|
| 180 | + fputs($fp, "Referer: $referer\r\n"); |
|
| 181 | + } |
|
| 182 | + if (isset($extra_headers) && is_array($extra_headers)) { |
|
| 183 | + foreach ($extra_headers as $curr_header) { |
|
| 184 | + fputs($fp, $curr_header . "\r\n"); |
|
| 185 | + } |
|
| 186 | + } |
|
| 187 | + if (!empty($user) && !empty($pass)) { |
|
| 188 | + fputs($fp, "Authorization: BASIC " . base64_encode("$user:$pass") . "\r\n"); |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + fputs($fp, "\r\n"); |
|
| 192 | + while (!feof($fp)) { |
|
| 193 | + $content .= fgets($fp, 4096); |
|
| 194 | + } |
|
| 195 | + fclose($fp); |
|
| 196 | + $csplit = preg_split("!\r\n\r\n!", $content, 2); |
|
| 197 | + |
|
| 198 | + $content = $csplit[ 1 ]; |
|
| 199 | + |
|
| 200 | + if (!empty($params[ 'assign_headers' ])) { |
|
| 201 | + $template->assign($params[ 'assign_headers' ], preg_split("!\r\n!", $csplit[ 0 ])); |
|
| 202 | + } |
|
| 203 | + } |
|
| 204 | + } else { |
|
| 205 | + trigger_error("[plugin fetch] unable to parse URL, check syntax", E_USER_NOTICE); |
|
| 206 | + |
|
| 207 | + return; |
|
| 208 | + } |
|
| 209 | + } else { |
|
| 210 | + $content = @file_get_contents($params[ 'file' ]); |
|
| 211 | + if ($content === false) { |
|
| 212 | + throw new SmartyException("{fetch} cannot read resource '" . $params[ 'file' ] . "'"); |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + if (!empty($params[ 'assign' ])) { |
|
| 217 | + $template->assign($params[ 'assign' ], $content); |
|
| 218 | + } else { |
|
| 219 | + return $content; |
|
| 220 | + } |
|
| 221 | 221 | } |
@@ -24,31 +24,31 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | function smarty_function_fetch($params, $template) |
| 26 | 26 | { |
| 27 | - if (empty($params[ 'file' ])) { |
|
| 27 | + if (empty($params['file'])) { |
|
| 28 | 28 | trigger_error("[plugin] fetch parameter 'file' cannot be empty", E_USER_NOTICE); |
| 29 | 29 | |
| 30 | 30 | return; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | // strip file protocol |
| 34 | - if (stripos($params[ 'file' ], 'file://') === 0) { |
|
| 35 | - $params[ 'file' ] = substr($params[ 'file' ], 7); |
|
| 34 | + if (stripos($params['file'], 'file://') === 0) { |
|
| 35 | + $params['file'] = substr($params['file'], 7); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - $protocol = strpos($params[ 'file' ], '://'); |
|
| 38 | + $protocol = strpos($params['file'], '://'); |
|
| 39 | 39 | if ($protocol !== false) { |
| 40 | - $protocol = strtolower(substr($params[ 'file' ], 0, $protocol)); |
|
| 40 | + $protocol = strtolower(substr($params['file'], 0, $protocol)); |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | if (isset($template->smarty->security_policy)) { |
| 44 | 44 | if ($protocol) { |
| 45 | 45 | // remote resource (or php stream, …) |
| 46 | - if (!$template->smarty->security_policy->isTrustedUri($params[ 'file' ])) { |
|
| 46 | + if (!$template->smarty->security_policy->isTrustedUri($params['file'])) { |
|
| 47 | 47 | return; |
| 48 | 48 | } |
| 49 | 49 | } else { |
| 50 | 50 | // local file |
| 51 | - if (!$template->smarty->security_policy->isTrustedResourceDir($params[ 'file' ])) { |
|
| 51 | + if (!$template->smarty->security_policy->isTrustedResourceDir($params['file'])) { |
|
| 52 | 52 | return; |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -57,26 +57,26 @@ discard block |
||
| 57 | 57 | $content = ''; |
| 58 | 58 | if ($protocol == 'http') { |
| 59 | 59 | // http fetch |
| 60 | - if ($uri_parts = parse_url($params[ 'file' ])) { |
|
| 60 | + if ($uri_parts = parse_url($params['file'])) { |
|
| 61 | 61 | // set defaults |
| 62 | - $host = $server_name = $uri_parts[ 'host' ]; |
|
| 62 | + $host = $server_name = $uri_parts['host']; |
|
| 63 | 63 | $timeout = 30; |
| 64 | 64 | $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; |
| 65 | 65 | $agent = "Smarty Template Engine " . Smarty::SMARTY_VERSION; |
| 66 | 66 | $referer = ""; |
| 67 | - $uri = !empty($uri_parts[ 'path' ]) ? $uri_parts[ 'path' ] : '/'; |
|
| 68 | - $uri .= !empty($uri_parts[ 'query' ]) ? '?' . $uri_parts[ 'query' ] : ''; |
|
| 67 | + $uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/'; |
|
| 68 | + $uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : ''; |
|
| 69 | 69 | $_is_proxy = false; |
| 70 | - if (empty($uri_parts[ 'port' ])) { |
|
| 70 | + if (empty($uri_parts['port'])) { |
|
| 71 | 71 | $port = 80; |
| 72 | 72 | } else { |
| 73 | - $port = $uri_parts[ 'port' ]; |
|
| 73 | + $port = $uri_parts['port']; |
|
| 74 | 74 | } |
| 75 | - if (!empty($uri_parts[ 'user' ])) { |
|
| 76 | - $user = $uri_parts[ 'user' ]; |
|
| 75 | + if (!empty($uri_parts['user'])) { |
|
| 76 | + $user = $uri_parts['user']; |
|
| 77 | 77 | } |
| 78 | - if (!empty($uri_parts[ 'pass' ])) { |
|
| 79 | - $pass = $uri_parts[ 'pass' ]; |
|
| 78 | + if (!empty($uri_parts['pass'])) { |
|
| 79 | + $pass = $uri_parts['pass']; |
|
| 80 | 80 | } |
| 81 | 81 | // loop through parameters, setup headers |
| 82 | 82 | foreach ($params as $param_key => $param_value) { |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | return; |
| 164 | 164 | } else { |
| 165 | 165 | if ($_is_proxy) { |
| 166 | - fputs($fp, 'GET ' . $params[ 'file' ] . " HTTP/1.0\r\n"); |
|
| 166 | + fputs($fp, 'GET ' . $params['file'] . " HTTP/1.0\r\n"); |
|
| 167 | 167 | } else { |
| 168 | 168 | fputs($fp, "GET $uri HTTP/1.0\r\n"); |
| 169 | 169 | } |
@@ -195,10 +195,10 @@ discard block |
||
| 195 | 195 | fclose($fp); |
| 196 | 196 | $csplit = preg_split("!\r\n\r\n!", $content, 2); |
| 197 | 197 | |
| 198 | - $content = $csplit[ 1 ]; |
|
| 198 | + $content = $csplit[1]; |
|
| 199 | 199 | |
| 200 | - if (!empty($params[ 'assign_headers' ])) { |
|
| 201 | - $template->assign($params[ 'assign_headers' ], preg_split("!\r\n!", $csplit[ 0 ])); |
|
| 200 | + if (!empty($params['assign_headers'])) { |
|
| 201 | + $template->assign($params['assign_headers'], preg_split("!\r\n!", $csplit[0])); |
|
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | } else { |
@@ -207,14 +207,14 @@ discard block |
||
| 207 | 207 | return; |
| 208 | 208 | } |
| 209 | 209 | } else { |
| 210 | - $content = @file_get_contents($params[ 'file' ]); |
|
| 210 | + $content = @file_get_contents($params['file']); |
|
| 211 | 211 | if ($content === false) { |
| 212 | - throw new SmartyException("{fetch} cannot read resource '" . $params[ 'file' ] . "'"); |
|
| 212 | + throw new SmartyException("{fetch} cannot read resource '" . $params['file'] . "'"); |
|
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - if (!empty($params[ 'assign' ])) { |
|
| 217 | - $template->assign($params[ 'assign' ], $content); |
|
| 216 | + if (!empty($params['assign'])) { |
|
| 217 | + $template->assign($params['assign'], $content); |
|
| 218 | 218 | } else { |
| 219 | 219 | return $content; |
| 220 | 220 | } |
@@ -8,68 +8,68 @@ |
||
| 8 | 8 | |
| 9 | 9 | if (!function_exists('smarty_mb_wordwrap')) { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * Wrap a string to a given number of characters |
|
| 13 | - * |
|
| 14 | - * @link http://php.net/manual/en/function.wordwrap.php for similarity |
|
| 15 | - * |
|
| 16 | - * @param string $str the string to wrap |
|
| 17 | - * @param int $width the width of the output |
|
| 18 | - * @param string $break the character used to break the line |
|
| 19 | - * @param boolean $cut ignored parameter, just for the sake of |
|
| 20 | - * |
|
| 21 | - * @return string wrapped string |
|
| 22 | - * @author Rodney Rehm |
|
| 23 | - */ |
|
| 24 | - function smarty_mb_wordwrap($str, $width = 75, $break = "\n", $cut = false) |
|
| 25 | - { |
|
| 26 | - // break words into tokens using white space as a delimiter |
|
| 27 | - $tokens = |
|
| 28 | - preg_split('!(\s)!S' . Smarty::$_UTF8_MODIFIER, $str, - 1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE); |
|
| 29 | - $length = 0; |
|
| 30 | - $t = ''; |
|
| 31 | - $_previous = false; |
|
| 32 | - $_space = false; |
|
| 11 | + /** |
|
| 12 | + * Wrap a string to a given number of characters |
|
| 13 | + * |
|
| 14 | + * @link http://php.net/manual/en/function.wordwrap.php for similarity |
|
| 15 | + * |
|
| 16 | + * @param string $str the string to wrap |
|
| 17 | + * @param int $width the width of the output |
|
| 18 | + * @param string $break the character used to break the line |
|
| 19 | + * @param boolean $cut ignored parameter, just for the sake of |
|
| 20 | + * |
|
| 21 | + * @return string wrapped string |
|
| 22 | + * @author Rodney Rehm |
|
| 23 | + */ |
|
| 24 | + function smarty_mb_wordwrap($str, $width = 75, $break = "\n", $cut = false) |
|
| 25 | + { |
|
| 26 | + // break words into tokens using white space as a delimiter |
|
| 27 | + $tokens = |
|
| 28 | + preg_split('!(\s)!S' . Smarty::$_UTF8_MODIFIER, $str, - 1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE); |
|
| 29 | + $length = 0; |
|
| 30 | + $t = ''; |
|
| 31 | + $_previous = false; |
|
| 32 | + $_space = false; |
|
| 33 | 33 | |
| 34 | - foreach ($tokens as $_token) { |
|
| 35 | - $token_length = mb_strlen($_token, Smarty::$_CHARSET); |
|
| 36 | - $_tokens = array($_token); |
|
| 37 | - if ($token_length > $width) { |
|
| 38 | - if ($cut) { |
|
| 39 | - $_tokens = preg_split('!(.{' . $width . '})!S' . Smarty::$_UTF8_MODIFIER, $_token, - 1, |
|
| 40 | - PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE); |
|
| 41 | - } |
|
| 42 | - } |
|
| 34 | + foreach ($tokens as $_token) { |
|
| 35 | + $token_length = mb_strlen($_token, Smarty::$_CHARSET); |
|
| 36 | + $_tokens = array($_token); |
|
| 37 | + if ($token_length > $width) { |
|
| 38 | + if ($cut) { |
|
| 39 | + $_tokens = preg_split('!(.{' . $width . '})!S' . Smarty::$_UTF8_MODIFIER, $_token, - 1, |
|
| 40 | + PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - foreach ($_tokens as $token) { |
|
| 45 | - $_space = !!preg_match('!^\s$!S' . Smarty::$_UTF8_MODIFIER, $token); |
|
| 46 | - $token_length = mb_strlen($token, Smarty::$_CHARSET); |
|
| 47 | - $length += $token_length; |
|
| 44 | + foreach ($_tokens as $token) { |
|
| 45 | + $_space = !!preg_match('!^\s$!S' . Smarty::$_UTF8_MODIFIER, $token); |
|
| 46 | + $token_length = mb_strlen($token, Smarty::$_CHARSET); |
|
| 47 | + $length += $token_length; |
|
| 48 | 48 | |
| 49 | - if ($length > $width) { |
|
| 50 | - // remove space before inserted break |
|
| 51 | - if ($_previous) { |
|
| 52 | - $t = mb_substr($t, 0, - 1, Smarty::$_CHARSET); |
|
| 53 | - } |
|
| 49 | + if ($length > $width) { |
|
| 50 | + // remove space before inserted break |
|
| 51 | + if ($_previous) { |
|
| 52 | + $t = mb_substr($t, 0, - 1, Smarty::$_CHARSET); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - if (!$_space) { |
|
| 56 | - // add the break before the token |
|
| 57 | - if (!empty($t)) { |
|
| 58 | - $t .= $break; |
|
| 59 | - } |
|
| 60 | - $length = $token_length; |
|
| 61 | - } |
|
| 62 | - } elseif ($token == "\n") { |
|
| 63 | - // hard break must reset counters |
|
| 64 | - $_previous = 0; |
|
| 65 | - $length = 0; |
|
| 66 | - } |
|
| 67 | - $_previous = $_space; |
|
| 68 | - // add the token |
|
| 69 | - $t .= $token; |
|
| 70 | - } |
|
| 71 | - } |
|
| 55 | + if (!$_space) { |
|
| 56 | + // add the break before the token |
|
| 57 | + if (!empty($t)) { |
|
| 58 | + $t .= $break; |
|
| 59 | + } |
|
| 60 | + $length = $token_length; |
|
| 61 | + } |
|
| 62 | + } elseif ($token == "\n") { |
|
| 63 | + // hard break must reset counters |
|
| 64 | + $_previous = 0; |
|
| 65 | + $length = 0; |
|
| 66 | + } |
|
| 67 | + $_previous = $_space; |
|
| 68 | + // add the token |
|
| 69 | + $t .= $token; |
|
| 70 | + } |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - return $t; |
|
| 74 | - } |
|
| 73 | + return $t; |
|
| 74 | + } |
|
| 75 | 75 | } |
@@ -24,177 +24,177 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true) |
| 26 | 26 | { |
| 27 | - static $_double_encode = null; |
|
| 28 | - if ($_double_encode === null) { |
|
| 29 | - $_double_encode = version_compare(PHP_VERSION, '5.2.3', '>='); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - if (!$char_set) { |
|
| 33 | - $char_set = Smarty::$_CHARSET; |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - switch ($esc_type) { |
|
| 37 | - case 'html': |
|
| 38 | - if ($_double_encode) { |
|
| 39 | - // php >=5.3.2 - go native |
|
| 40 | - return htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode); |
|
| 41 | - } else { |
|
| 42 | - if ($double_encode) { |
|
| 43 | - // php <5.2.3 - only handle double encoding |
|
| 44 | - return htmlspecialchars($string, ENT_QUOTES, $char_set); |
|
| 45 | - } else { |
|
| 46 | - // php <5.2.3 - prevent double encoding |
|
| 47 | - $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); |
|
| 48 | - $string = htmlspecialchars($string, ENT_QUOTES, $char_set); |
|
| 49 | - $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); |
|
| 50 | - |
|
| 51 | - return $string; |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - case 'htmlall': |
|
| 56 | - if (Smarty::$_MBSTRING) { |
|
| 57 | - // mb_convert_encoding ignores htmlspecialchars() |
|
| 58 | - if ($_double_encode) { |
|
| 59 | - // php >=5.3.2 - go native |
|
| 60 | - $string = htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode); |
|
| 61 | - } else { |
|
| 62 | - if ($double_encode) { |
|
| 63 | - // php <5.2.3 - only handle double encoding |
|
| 64 | - $string = htmlspecialchars($string, ENT_QUOTES, $char_set); |
|
| 65 | - } else { |
|
| 66 | - // php <5.2.3 - prevent double encoding |
|
| 67 | - $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); |
|
| 68 | - $string = htmlspecialchars($string, ENT_QUOTES, $char_set); |
|
| 69 | - $string = |
|
| 70 | - str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); |
|
| 71 | - |
|
| 72 | - return $string; |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - // htmlentities() won't convert everything, so use mb_convert_encoding |
|
| 77 | - return mb_convert_encoding($string, 'HTML-ENTITIES', $char_set); |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - // no MBString fallback |
|
| 81 | - if ($_double_encode) { |
|
| 82 | - return htmlentities($string, ENT_QUOTES, $char_set, $double_encode); |
|
| 83 | - } else { |
|
| 84 | - if ($double_encode) { |
|
| 85 | - return htmlentities($string, ENT_QUOTES, $char_set); |
|
| 86 | - } else { |
|
| 87 | - $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); |
|
| 88 | - $string = htmlentities($string, ENT_QUOTES, $char_set); |
|
| 89 | - $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); |
|
| 90 | - |
|
| 91 | - return $string; |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - case 'url': |
|
| 96 | - return rawurlencode($string); |
|
| 97 | - |
|
| 98 | - case 'urlpathinfo': |
|
| 99 | - return str_replace('%2F', '/', rawurlencode($string)); |
|
| 100 | - |
|
| 101 | - case 'quotes': |
|
| 102 | - // escape unescaped single quotes |
|
| 103 | - return preg_replace("%(?<!\\\\)'%", "\\'", $string); |
|
| 104 | - |
|
| 105 | - case 'hex': |
|
| 106 | - // escape every byte into hex |
|
| 107 | - // Note that the UTF-8 encoded character ä will be represented as %c3%a4 |
|
| 108 | - $return = ''; |
|
| 109 | - $_length = strlen($string); |
|
| 110 | - for ($x = 0; $x < $_length; $x ++) { |
|
| 111 | - $return .= '%' . bin2hex($string[ $x ]); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - return $return; |
|
| 115 | - |
|
| 116 | - case 'hexentity': |
|
| 117 | - $return = ''; |
|
| 118 | - if (Smarty::$_MBSTRING) { |
|
| 119 | - require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php'); |
|
| 120 | - $return = ''; |
|
| 121 | - foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) { |
|
| 122 | - $return .= '&#x' . strtoupper(dechex($unicode)) . ';'; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - return $return; |
|
| 126 | - } |
|
| 127 | - // no MBString fallback |
|
| 128 | - $_length = strlen($string); |
|
| 129 | - for ($x = 0; $x < $_length; $x ++) { |
|
| 130 | - $return .= '&#x' . bin2hex($string[ $x ]) . ';'; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - return $return; |
|
| 134 | - |
|
| 135 | - case 'decentity': |
|
| 136 | - $return = ''; |
|
| 137 | - if (Smarty::$_MBSTRING) { |
|
| 138 | - require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php'); |
|
| 139 | - $return = ''; |
|
| 140 | - foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) { |
|
| 141 | - $return .= '&#' . $unicode . ';'; |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - return $return; |
|
| 145 | - } |
|
| 146 | - // no MBString fallback |
|
| 147 | - $_length = strlen($string); |
|
| 148 | - for ($x = 0; $x < $_length; $x ++) { |
|
| 149 | - $return .= '&#' . ord($string[ $x ]) . ';'; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - return $return; |
|
| 153 | - |
|
| 154 | - case 'javascript': |
|
| 155 | - // escape quotes and backslashes, newlines, etc. |
|
| 156 | - return strtr($string, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', |
|
| 157 | - '</' => '<\/')); |
|
| 158 | - |
|
| 159 | - case 'mail': |
|
| 160 | - if (Smarty::$_MBSTRING) { |
|
| 161 | - require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'); |
|
| 162 | - |
|
| 163 | - return smarty_mb_str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string); |
|
| 164 | - } |
|
| 165 | - // no MBString fallback |
|
| 166 | - return str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string); |
|
| 167 | - |
|
| 168 | - case 'nonstd': |
|
| 169 | - // escape non-standard chars, such as ms document quotes |
|
| 170 | - $return = ''; |
|
| 171 | - if (Smarty::$_MBSTRING) { |
|
| 172 | - require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php'); |
|
| 173 | - foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) { |
|
| 174 | - if ($unicode >= 126) { |
|
| 175 | - $return .= '&#' . $unicode . ';'; |
|
| 176 | - } else { |
|
| 177 | - $return .= chr($unicode); |
|
| 178 | - } |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - return $return; |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - $_length = strlen($string); |
|
| 185 | - for ($_i = 0; $_i < $_length; $_i ++) { |
|
| 186 | - $_ord = ord(substr($string, $_i, 1)); |
|
| 187 | - // non-standard char, escape it |
|
| 188 | - if ($_ord >= 126) { |
|
| 189 | - $return .= '&#' . $_ord . ';'; |
|
| 190 | - } else { |
|
| 191 | - $return .= substr($string, $_i, 1); |
|
| 192 | - } |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - return $return; |
|
| 196 | - |
|
| 197 | - default: |
|
| 198 | - return $string; |
|
| 199 | - } |
|
| 27 | + static $_double_encode = null; |
|
| 28 | + if ($_double_encode === null) { |
|
| 29 | + $_double_encode = version_compare(PHP_VERSION, '5.2.3', '>='); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + if (!$char_set) { |
|
| 33 | + $char_set = Smarty::$_CHARSET; |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + switch ($esc_type) { |
|
| 37 | + case 'html': |
|
| 38 | + if ($_double_encode) { |
|
| 39 | + // php >=5.3.2 - go native |
|
| 40 | + return htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode); |
|
| 41 | + } else { |
|
| 42 | + if ($double_encode) { |
|
| 43 | + // php <5.2.3 - only handle double encoding |
|
| 44 | + return htmlspecialchars($string, ENT_QUOTES, $char_set); |
|
| 45 | + } else { |
|
| 46 | + // php <5.2.3 - prevent double encoding |
|
| 47 | + $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); |
|
| 48 | + $string = htmlspecialchars($string, ENT_QUOTES, $char_set); |
|
| 49 | + $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); |
|
| 50 | + |
|
| 51 | + return $string; |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + case 'htmlall': |
|
| 56 | + if (Smarty::$_MBSTRING) { |
|
| 57 | + // mb_convert_encoding ignores htmlspecialchars() |
|
| 58 | + if ($_double_encode) { |
|
| 59 | + // php >=5.3.2 - go native |
|
| 60 | + $string = htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode); |
|
| 61 | + } else { |
|
| 62 | + if ($double_encode) { |
|
| 63 | + // php <5.2.3 - only handle double encoding |
|
| 64 | + $string = htmlspecialchars($string, ENT_QUOTES, $char_set); |
|
| 65 | + } else { |
|
| 66 | + // php <5.2.3 - prevent double encoding |
|
| 67 | + $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); |
|
| 68 | + $string = htmlspecialchars($string, ENT_QUOTES, $char_set); |
|
| 69 | + $string = |
|
| 70 | + str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); |
|
| 71 | + |
|
| 72 | + return $string; |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + // htmlentities() won't convert everything, so use mb_convert_encoding |
|
| 77 | + return mb_convert_encoding($string, 'HTML-ENTITIES', $char_set); |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + // no MBString fallback |
|
| 81 | + if ($_double_encode) { |
|
| 82 | + return htmlentities($string, ENT_QUOTES, $char_set, $double_encode); |
|
| 83 | + } else { |
|
| 84 | + if ($double_encode) { |
|
| 85 | + return htmlentities($string, ENT_QUOTES, $char_set); |
|
| 86 | + } else { |
|
| 87 | + $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); |
|
| 88 | + $string = htmlentities($string, ENT_QUOTES, $char_set); |
|
| 89 | + $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); |
|
| 90 | + |
|
| 91 | + return $string; |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + case 'url': |
|
| 96 | + return rawurlencode($string); |
|
| 97 | + |
|
| 98 | + case 'urlpathinfo': |
|
| 99 | + return str_replace('%2F', '/', rawurlencode($string)); |
|
| 100 | + |
|
| 101 | + case 'quotes': |
|
| 102 | + // escape unescaped single quotes |
|
| 103 | + return preg_replace("%(?<!\\\\)'%", "\\'", $string); |
|
| 104 | + |
|
| 105 | + case 'hex': |
|
| 106 | + // escape every byte into hex |
|
| 107 | + // Note that the UTF-8 encoded character ä will be represented as %c3%a4 |
|
| 108 | + $return = ''; |
|
| 109 | + $_length = strlen($string); |
|
| 110 | + for ($x = 0; $x < $_length; $x ++) { |
|
| 111 | + $return .= '%' . bin2hex($string[ $x ]); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + return $return; |
|
| 115 | + |
|
| 116 | + case 'hexentity': |
|
| 117 | + $return = ''; |
|
| 118 | + if (Smarty::$_MBSTRING) { |
|
| 119 | + require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php'); |
|
| 120 | + $return = ''; |
|
| 121 | + foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) { |
|
| 122 | + $return .= '&#x' . strtoupper(dechex($unicode)) . ';'; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + return $return; |
|
| 126 | + } |
|
| 127 | + // no MBString fallback |
|
| 128 | + $_length = strlen($string); |
|
| 129 | + for ($x = 0; $x < $_length; $x ++) { |
|
| 130 | + $return .= '&#x' . bin2hex($string[ $x ]) . ';'; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + return $return; |
|
| 134 | + |
|
| 135 | + case 'decentity': |
|
| 136 | + $return = ''; |
|
| 137 | + if (Smarty::$_MBSTRING) { |
|
| 138 | + require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php'); |
|
| 139 | + $return = ''; |
|
| 140 | + foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) { |
|
| 141 | + $return .= '&#' . $unicode . ';'; |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + return $return; |
|
| 145 | + } |
|
| 146 | + // no MBString fallback |
|
| 147 | + $_length = strlen($string); |
|
| 148 | + for ($x = 0; $x < $_length; $x ++) { |
|
| 149 | + $return .= '&#' . ord($string[ $x ]) . ';'; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + return $return; |
|
| 153 | + |
|
| 154 | + case 'javascript': |
|
| 155 | + // escape quotes and backslashes, newlines, etc. |
|
| 156 | + return strtr($string, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', |
|
| 157 | + '</' => '<\/')); |
|
| 158 | + |
|
| 159 | + case 'mail': |
|
| 160 | + if (Smarty::$_MBSTRING) { |
|
| 161 | + require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'); |
|
| 162 | + |
|
| 163 | + return smarty_mb_str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string); |
|
| 164 | + } |
|
| 165 | + // no MBString fallback |
|
| 166 | + return str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string); |
|
| 167 | + |
|
| 168 | + case 'nonstd': |
|
| 169 | + // escape non-standard chars, such as ms document quotes |
|
| 170 | + $return = ''; |
|
| 171 | + if (Smarty::$_MBSTRING) { |
|
| 172 | + require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php'); |
|
| 173 | + foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) { |
|
| 174 | + if ($unicode >= 126) { |
|
| 175 | + $return .= '&#' . $unicode . ';'; |
|
| 176 | + } else { |
|
| 177 | + $return .= chr($unicode); |
|
| 178 | + } |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + return $return; |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + $_length = strlen($string); |
|
| 185 | + for ($_i = 0; $_i < $_length; $_i ++) { |
|
| 186 | + $_ord = ord(substr($string, $_i, 1)); |
|
| 187 | + // non-standard char, escape it |
|
| 188 | + if ($_ord >= 126) { |
|
| 189 | + $return .= '&#' . $_ord . ';'; |
|
| 190 | + } else { |
|
| 191 | + $return .= substr($string, $_i, 1); |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + return $return; |
|
| 196 | + |
|
| 197 | + default: |
|
| 198 | + return $string; |
|
| 199 | + } |
|
| 200 | 200 | } |
@@ -107,8 +107,8 @@ discard block |
||
| 107 | 107 | // Note that the UTF-8 encoded character ä will be represented as %c3%a4 |
| 108 | 108 | $return = ''; |
| 109 | 109 | $_length = strlen($string); |
| 110 | - for ($x = 0; $x < $_length; $x ++) { |
|
| 111 | - $return .= '%' . bin2hex($string[ $x ]); |
|
| 110 | + for ($x = 0; $x < $_length; $x++) { |
|
| 111 | + $return .= '%' . bin2hex($string[$x]); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | return $return; |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | // no MBString fallback |
| 128 | 128 | $_length = strlen($string); |
| 129 | - for ($x = 0; $x < $_length; $x ++) { |
|
| 130 | - $return .= '&#x' . bin2hex($string[ $x ]) . ';'; |
|
| 129 | + for ($x = 0; $x < $_length; $x++) { |
|
| 130 | + $return .= '&#x' . bin2hex($string[$x]) . ';'; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | return $return; |
@@ -145,8 +145,8 @@ discard block |
||
| 145 | 145 | } |
| 146 | 146 | // no MBString fallback |
| 147 | 147 | $_length = strlen($string); |
| 148 | - for ($x = 0; $x < $_length; $x ++) { |
|
| 149 | - $return .= '&#' . ord($string[ $x ]) . ';'; |
|
| 148 | + for ($x = 0; $x < $_length; $x++) { |
|
| 149 | + $return .= '&#' . ord($string[$x]) . ';'; |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | return $return; |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | $_length = strlen($string); |
| 185 | - for ($_i = 0; $_i < $_length; $_i ++) { |
|
| 185 | + for ($_i = 0; $_i < $_length; $_i++) { |
|
| 186 | 186 | $_ord = ord(substr($string, $_i, 1)); |
| 187 | 187 | // non-standard char, escape it |
| 188 | 188 | if ($_ord >= 126) { |
@@ -21,9 +21,9 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | function smarty_modifiercompiler_upper($params) |
| 23 | 23 | { |
| 24 | - if (Smarty::$_MBSTRING) { |
|
| 25 | - return 'mb_strtoupper(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; |
|
| 26 | - } |
|
| 27 | - // no MBString fallback |
|
| 28 | - return 'strtoupper(' . $params[ 0 ] . ')'; |
|
| 24 | + if (Smarty::$_MBSTRING) { |
|
| 25 | + return 'mb_strtoupper(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; |
|
| 26 | + } |
|
| 27 | + // no MBString fallback |
|
| 28 | + return 'strtoupper(' . $params[ 0 ] . ')'; |
|
| 29 | 29 | } |
@@ -22,8 +22,8 @@ |
||
| 22 | 22 | function smarty_modifiercompiler_upper($params) |
| 23 | 23 | { |
| 24 | 24 | if (Smarty::$_MBSTRING) { |
| 25 | - return 'mb_strtoupper(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; |
|
| 25 | + return 'mb_strtoupper(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; |
|
| 26 | 26 | } |
| 27 | 27 | // no MBString fallback |
| 28 | - return 'strtoupper(' . $params[ 0 ] . ')'; |
|
| 28 | + return 'strtoupper(' . $params[0] . ')'; |
|
| 29 | 29 | } |
@@ -22,30 +22,30 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | function smarty_modifiercompiler_wordwrap($params, $compiler) |
| 24 | 24 | { |
| 25 | - if (!isset($params[ 1 ])) { |
|
| 26 | - $params[ 1 ] = 80; |
|
| 27 | - } |
|
| 28 | - if (!isset($params[ 2 ])) { |
|
| 29 | - $params[ 2 ] = '"\n"'; |
|
| 30 | - } |
|
| 31 | - if (!isset($params[ 3 ])) { |
|
| 32 | - $params[ 3 ] = 'false'; |
|
| 33 | - } |
|
| 34 | - $function = 'wordwrap'; |
|
| 35 | - if (Smarty::$_MBSTRING) { |
|
| 36 | - if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) { |
|
| 37 | - $compiler->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ 'wordwrap' ][ 'modifier' ][ 'file' ] = |
|
| 38 | - SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php'; |
|
| 39 | - $compiler->template->required_plugins[ 'nocache' ][ 'wordwrap' ][ 'modifier' ][ 'function' ] = |
|
| 40 | - 'smarty_mb_wordwrap'; |
|
| 41 | - } else { |
|
| 42 | - $compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ 'wordwrap' ][ 'modifier' ][ 'file' ] = |
|
| 43 | - SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php'; |
|
| 44 | - $compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ 'wordwrap' ][ 'modifier' ][ 'function' ] = |
|
| 45 | - 'smarty_mb_wordwrap'; |
|
| 46 | - } |
|
| 47 | - $function = 'smarty_mb_wordwrap'; |
|
| 48 | - } |
|
| 25 | + if (!isset($params[ 1 ])) { |
|
| 26 | + $params[ 1 ] = 80; |
|
| 27 | + } |
|
| 28 | + if (!isset($params[ 2 ])) { |
|
| 29 | + $params[ 2 ] = '"\n"'; |
|
| 30 | + } |
|
| 31 | + if (!isset($params[ 3 ])) { |
|
| 32 | + $params[ 3 ] = 'false'; |
|
| 33 | + } |
|
| 34 | + $function = 'wordwrap'; |
|
| 35 | + if (Smarty::$_MBSTRING) { |
|
| 36 | + if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) { |
|
| 37 | + $compiler->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ 'wordwrap' ][ 'modifier' ][ 'file' ] = |
|
| 38 | + SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php'; |
|
| 39 | + $compiler->template->required_plugins[ 'nocache' ][ 'wordwrap' ][ 'modifier' ][ 'function' ] = |
|
| 40 | + 'smarty_mb_wordwrap'; |
|
| 41 | + } else { |
|
| 42 | + $compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ 'wordwrap' ][ 'modifier' ][ 'file' ] = |
|
| 43 | + SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php'; |
|
| 44 | + $compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ 'wordwrap' ][ 'modifier' ][ 'function' ] = |
|
| 45 | + 'smarty_mb_wordwrap'; |
|
| 46 | + } |
|
| 47 | + $function = 'smarty_mb_wordwrap'; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - return $function . '(' . $params[ 0 ] . ',' . $params[ 1 ] . ',' . $params[ 2 ] . ',' . $params[ 3 ] . ')'; |
|
| 50 | + return $function . '(' . $params[ 0 ] . ',' . $params[ 1 ] . ',' . $params[ 2 ] . ',' . $params[ 3 ] . ')'; |
|
| 51 | 51 | } |
@@ -22,30 +22,30 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | function smarty_modifiercompiler_wordwrap($params, $compiler) |
| 24 | 24 | { |
| 25 | - if (!isset($params[ 1 ])) { |
|
| 26 | - $params[ 1 ] = 80; |
|
| 25 | + if (!isset($params[1])) { |
|
| 26 | + $params[1] = 80; |
|
| 27 | 27 | } |
| 28 | - if (!isset($params[ 2 ])) { |
|
| 29 | - $params[ 2 ] = '"\n"'; |
|
| 28 | + if (!isset($params[2])) { |
|
| 29 | + $params[2] = '"\n"'; |
|
| 30 | 30 | } |
| 31 | - if (!isset($params[ 3 ])) { |
|
| 32 | - $params[ 3 ] = 'false'; |
|
| 31 | + if (!isset($params[3])) { |
|
| 32 | + $params[3] = 'false'; |
|
| 33 | 33 | } |
| 34 | 34 | $function = 'wordwrap'; |
| 35 | 35 | if (Smarty::$_MBSTRING) { |
| 36 | 36 | if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) { |
| 37 | - $compiler->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ 'wordwrap' ][ 'modifier' ][ 'file' ] = |
|
| 37 | + $compiler->parent_compiler->template->compiled->required_plugins['nocache']['wordwrap']['modifier']['file'] = |
|
| 38 | 38 | SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php'; |
| 39 | - $compiler->template->required_plugins[ 'nocache' ][ 'wordwrap' ][ 'modifier' ][ 'function' ] = |
|
| 39 | + $compiler->template->required_plugins['nocache']['wordwrap']['modifier']['function'] = |
|
| 40 | 40 | 'smarty_mb_wordwrap'; |
| 41 | 41 | } else { |
| 42 | - $compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ 'wordwrap' ][ 'modifier' ][ 'file' ] = |
|
| 42 | + $compiler->parent_compiler->template->compiled->required_plugins['compiled']['wordwrap']['modifier']['file'] = |
|
| 43 | 43 | SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php'; |
| 44 | - $compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ 'wordwrap' ][ 'modifier' ][ 'function' ] = |
|
| 44 | + $compiler->parent_compiler->template->compiled->required_plugins['compiled']['wordwrap']['modifier']['function'] = |
|
| 45 | 45 | 'smarty_mb_wordwrap'; |
| 46 | 46 | } |
| 47 | 47 | $function = 'smarty_mb_wordwrap'; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - return $function . '(' . $params[ 0 ] . ',' . $params[ 1 ] . ',' . $params[ 2 ] . ',' . $params[ 3 ] . ')'; |
|
| 50 | + return $function . '(' . $params[0] . ',' . $params[1] . ',' . $params[2] . ',' . $params[3] . ')'; |
|
| 51 | 51 | } |
@@ -19,70 +19,70 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | function smarty_outputfilter_trimwhitespace($source) |
| 21 | 21 | { |
| 22 | - $store = array(); |
|
| 23 | - $_store = 0; |
|
| 24 | - $_offset = 0; |
|
| 22 | + $store = array(); |
|
| 23 | + $_store = 0; |
|
| 24 | + $_offset = 0; |
|
| 25 | 25 | |
| 26 | - // Unify Line-Breaks to \n |
|
| 27 | - $source = preg_replace("/\015\012|\015|\012/", "\n", $source); |
|
| 26 | + // Unify Line-Breaks to \n |
|
| 27 | + $source = preg_replace("/\015\012|\015|\012/", "\n", $source); |
|
| 28 | 28 | |
| 29 | - // capture Internet Explorer and KnockoutJS Conditional Comments |
|
| 30 | - if (preg_match_all('#<!--((\[[^\]]+\]>.*?<!\[[^\]]+\])|(\s*/?ko\s+.+))-->#is', $source, $matches, |
|
| 31 | - PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
|
| 32 | - foreach ($matches as $match) { |
|
| 33 | - $store[] = $match[ 0 ][ 0 ]; |
|
| 34 | - $_length = strlen($match[ 0 ][ 0 ]); |
|
| 35 | - $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; |
|
| 36 | - $source = substr_replace($source, $replace, $match[ 0 ][ 1 ] - $_offset, $_length); |
|
| 29 | + // capture Internet Explorer and KnockoutJS Conditional Comments |
|
| 30 | + if (preg_match_all('#<!--((\[[^\]]+\]>.*?<!\[[^\]]+\])|(\s*/?ko\s+.+))-->#is', $source, $matches, |
|
| 31 | + PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
|
| 32 | + foreach ($matches as $match) { |
|
| 33 | + $store[] = $match[ 0 ][ 0 ]; |
|
| 34 | + $_length = strlen($match[ 0 ][ 0 ]); |
|
| 35 | + $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; |
|
| 36 | + $source = substr_replace($source, $replace, $match[ 0 ][ 1 ] - $_offset, $_length); |
|
| 37 | 37 | |
| 38 | - $_offset += $_length - strlen($replace); |
|
| 39 | - $_store ++; |
|
| 40 | - } |
|
| 41 | - } |
|
| 38 | + $_offset += $_length - strlen($replace); |
|
| 39 | + $_store ++; |
|
| 40 | + } |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - // Strip all HTML-Comments |
|
| 44 | - // yes, even the ones in <script> - see http://stackoverflow.com/a/808850/515124 |
|
| 45 | - $source = preg_replace('#<!--.*?-->#ms', '', $source); |
|
| 43 | + // Strip all HTML-Comments |
|
| 44 | + // yes, even the ones in <script> - see http://stackoverflow.com/a/808850/515124 |
|
| 45 | + $source = preg_replace('#<!--.*?-->#ms', '', $source); |
|
| 46 | 46 | |
| 47 | - // capture html elements not to be messed with |
|
| 48 | - $_offset = 0; |
|
| 49 | - if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is', |
|
| 50 | - $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
|
| 51 | - foreach ($matches as $match) { |
|
| 52 | - $store[] = $match[ 0 ][ 0 ]; |
|
| 53 | - $_length = strlen($match[ 0 ][ 0 ]); |
|
| 54 | - $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; |
|
| 55 | - $source = substr_replace($source, $replace, $match[ 0 ][ 1 ] - $_offset, $_length); |
|
| 47 | + // capture html elements not to be messed with |
|
| 48 | + $_offset = 0; |
|
| 49 | + if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is', |
|
| 50 | + $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
|
| 51 | + foreach ($matches as $match) { |
|
| 52 | + $store[] = $match[ 0 ][ 0 ]; |
|
| 53 | + $_length = strlen($match[ 0 ][ 0 ]); |
|
| 54 | + $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; |
|
| 55 | + $source = substr_replace($source, $replace, $match[ 0 ][ 1 ] - $_offset, $_length); |
|
| 56 | 56 | |
| 57 | - $_offset += $_length - strlen($replace); |
|
| 58 | - $_store ++; |
|
| 59 | - } |
|
| 60 | - } |
|
| 57 | + $_offset += $_length - strlen($replace); |
|
| 58 | + $_store ++; |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - $expressions = array(// replace multiple spaces between tags by a single space |
|
| 63 | - // can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements |
|
| 64 | - '#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2', |
|
| 65 | - // remove spaces between attributes (but not in attribute values!) |
|
| 66 | - '#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5', |
|
| 67 | - // note: for some very weird reason trim() seems to remove spaces inside attributes. |
|
| 68 | - // maybe a \0 byte or something is interfering? |
|
| 69 | - '#^\s+<#Ss' => '<', '#>\s+$#Ss' => '>',); |
|
| 62 | + $expressions = array(// replace multiple spaces between tags by a single space |
|
| 63 | + // can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements |
|
| 64 | + '#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2', |
|
| 65 | + // remove spaces between attributes (but not in attribute values!) |
|
| 66 | + '#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5', |
|
| 67 | + // note: for some very weird reason trim() seems to remove spaces inside attributes. |
|
| 68 | + // maybe a \0 byte or something is interfering? |
|
| 69 | + '#^\s+<#Ss' => '<', '#>\s+$#Ss' => '>',); |
|
| 70 | 70 | |
| 71 | - $source = preg_replace(array_keys($expressions), array_values($expressions), $source); |
|
| 72 | - // note: for some very weird reason trim() seems to remove spaces inside attributes. |
|
| 73 | - // maybe a \0 byte or something is interfering? |
|
| 71 | + $source = preg_replace(array_keys($expressions), array_values($expressions), $source); |
|
| 72 | + // note: for some very weird reason trim() seems to remove spaces inside attributes. |
|
| 73 | + // maybe a \0 byte or something is interfering? |
|
| 74 | 74 | |
| 75 | - $_offset = 0; |
|
| 76 | - if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
|
| 77 | - foreach ($matches as $match) { |
|
| 78 | - $_length = strlen($match[ 0 ][ 0 ]); |
|
| 79 | - $replace = $store[ $match[ 1 ][ 0 ] ]; |
|
| 80 | - $source = substr_replace($source, $replace, $match[ 0 ][ 1 ] + $_offset, $_length); |
|
| 75 | + $_offset = 0; |
|
| 76 | + if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
|
| 77 | + foreach ($matches as $match) { |
|
| 78 | + $_length = strlen($match[ 0 ][ 0 ]); |
|
| 79 | + $replace = $store[ $match[ 1 ][ 0 ] ]; |
|
| 80 | + $source = substr_replace($source, $replace, $match[ 0 ][ 1 ] + $_offset, $_length); |
|
| 81 | 81 | |
| 82 | - $_offset += strlen($replace) - $_length; |
|
| 83 | - $_store ++; |
|
| 84 | - } |
|
| 85 | - } |
|
| 82 | + $_offset += strlen($replace) - $_length; |
|
| 83 | + $_store ++; |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - return $source; |
|
| 87 | + return $source; |
|
| 88 | 88 | } |
@@ -30,13 +30,13 @@ discard block |
||
| 30 | 30 | if (preg_match_all('#<!--((\[[^\]]+\]>.*?<!\[[^\]]+\])|(\s*/?ko\s+.+))-->#is', $source, $matches, |
| 31 | 31 | PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
| 32 | 32 | foreach ($matches as $match) { |
| 33 | - $store[] = $match[ 0 ][ 0 ]; |
|
| 34 | - $_length = strlen($match[ 0 ][ 0 ]); |
|
| 33 | + $store[] = $match[0][0]; |
|
| 34 | + $_length = strlen($match[0][0]); |
|
| 35 | 35 | $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; |
| 36 | - $source = substr_replace($source, $replace, $match[ 0 ][ 1 ] - $_offset, $_length); |
|
| 36 | + $source = substr_replace($source, $replace, $match[0][1] - $_offset, $_length); |
|
| 37 | 37 | |
| 38 | 38 | $_offset += $_length - strlen($replace); |
| 39 | - $_store ++; |
|
| 39 | + $_store++; |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
@@ -49,13 +49,13 @@ discard block |
||
| 49 | 49 | if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is', |
| 50 | 50 | $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
| 51 | 51 | foreach ($matches as $match) { |
| 52 | - $store[] = $match[ 0 ][ 0 ]; |
|
| 53 | - $_length = strlen($match[ 0 ][ 0 ]); |
|
| 52 | + $store[] = $match[0][0]; |
|
| 53 | + $_length = strlen($match[0][0]); |
|
| 54 | 54 | $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; |
| 55 | - $source = substr_replace($source, $replace, $match[ 0 ][ 1 ] - $_offset, $_length); |
|
| 55 | + $source = substr_replace($source, $replace, $match[0][1] - $_offset, $_length); |
|
| 56 | 56 | |
| 57 | 57 | $_offset += $_length - strlen($replace); |
| 58 | - $_store ++; |
|
| 58 | + $_store++; |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
@@ -75,12 +75,12 @@ discard block |
||
| 75 | 75 | $_offset = 0; |
| 76 | 76 | if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
| 77 | 77 | foreach ($matches as $match) { |
| 78 | - $_length = strlen($match[ 0 ][ 0 ]); |
|
| 79 | - $replace = $store[ $match[ 1 ][ 0 ] ]; |
|
| 80 | - $source = substr_replace($source, $replace, $match[ 0 ][ 1 ] + $_offset, $_length); |
|
| 78 | + $_length = strlen($match[0][0]); |
|
| 79 | + $replace = $store[$match[1][0]]; |
|
| 80 | + $source = substr_replace($source, $replace, $match[0][1] + $_offset, $_length); |
|
| 81 | 81 | |
| 82 | 82 | $_offset += strlen($replace) - $_length; |
| 83 | - $_store ++; |
|
| 83 | + $_store++; |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
@@ -22,6 +22,6 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | function smarty_modifiercompiler_count_sentences($params) |
| 24 | 24 | { |
| 25 | - // find periods, question marks, exclamation marks with a word before but not after. |
|
| 26 | - return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[ 0 ] . ', $tmp)'; |
|
| 25 | + // find periods, question marks, exclamation marks with a word before but not after. |
|
| 26 | + return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[ 0 ] . ', $tmp)'; |
|
| 27 | 27 | } |
@@ -23,5 +23,5 @@ |
||
| 23 | 23 | function smarty_modifiercompiler_count_sentences($params) |
| 24 | 24 | { |
| 25 | 25 | // find periods, question marks, exclamation marks with a word before but not after. |
| 26 | - return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[ 0 ] . ', $tmp)'; |
|
| 26 | + return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[0] . ', $tmp)'; |
|
| 27 | 27 | } |