@@ -2,108 +2,108 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class SectionIO extends Object implements Flushable |
| 4 | 4 | { |
| 5 | - private static $flush_on_dev_build = true; |
|
| 6 | - |
|
| 7 | - private static $sitetree_flush_strategy = 'single'; |
|
| 8 | - |
|
| 9 | - private static $api_url = 'https://aperture.section.io/api/v1'; |
|
| 10 | - private static $account_id = ''; |
|
| 11 | - private static $application_id = ''; |
|
| 12 | - private static $environment_name = ''; |
|
| 13 | - private static $proxy_name = ''; |
|
| 14 | - private static $username = ''; |
|
| 15 | - private static $password = ''; |
|
| 16 | - |
|
| 17 | - /** |
|
| 18 | - * Implementation of Flushable::flush() |
|
| 19 | - * Is triggered on dev/build and ?flush=1. |
|
| 20 | - */ |
|
| 21 | - public static function flush() |
|
| 22 | - { |
|
| 23 | - if (Config::inst()->get('SectionIO', 'flush_on_dev_build')) { |
|
| 24 | - return static::flushAll(); |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - return; |
|
| 28 | - } |
|
| 29 | - |
|
| 30 | - public static function flushAll() |
|
| 31 | - { |
|
| 32 | - $exp = 'obj.http.x-url ~ /'; |
|
| 33 | - |
|
| 34 | - return static::performFlush($exp); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - public static function flushImage($imageID) |
|
| 38 | - { |
|
| 39 | - $image = Image::get()->byID($imageID); |
|
| 40 | - if ($image && $image->exists()) { |
|
| 41 | - $exp = 'obj.http.x-url ~ "^/'.preg_quote($image->getFilename()).'$"'; // image itself |
|
| 42 | - $exp .= ' || obj.http.x-url ~ "^/'.preg_quote($image->Parent()->getFilename()) |
|
| 43 | - .'_resampled/(.*)\-'.preg_quote($image->Name).'$"'; // resampled versions |
|
| 44 | - return static::performFlush($exp); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - return false; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - public static function flushFile($fileID) |
|
| 51 | - { |
|
| 52 | - $file = File::get()->byID($fileID); |
|
| 53 | - if ($file && $file->exists()) { |
|
| 54 | - $exp = 'obj.http.x-url ~ "^/'.preg_quote($file->getFilename()).'$"'; |
|
| 55 | - |
|
| 56 | - return static::performFlush($exp); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - return false; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - public static function flushSiteTree($sitetreeID) |
|
| 63 | - { |
|
| 64 | - $sitetree = SiteTree::get()->byID($sitetreeID); |
|
| 65 | - if ($sitetree && $sitetree->exists()) { |
|
| 66 | - $strategy = Config::inst()->get('SectionIO', 'sitetree_flush_strategy'); |
|
| 67 | - switch ($strategy) { |
|
| 68 | - |
|
| 69 | - case 'single': |
|
| 70 | - $exp = 'obj.http.content-type ~ "'.preg_quote('text/html').'"'; |
|
| 71 | - $exp .= ' && obj.http.x-url ~ "^'.preg_quote($sitetree->Link()).'$"'; |
|
| 72 | - break; |
|
| 73 | - |
|
| 74 | - case 'parents': |
|
| 75 | - $exp = 'obj.http.content-type ~ "'.preg_quote('text/html').'"'; |
|
| 76 | - $exp .= ' && (obj.http.x-url ~ "^'.preg_quote($sitetree->Link()).'$"'; |
|
| 77 | - $parent = $sitetree->getParent(); |
|
| 78 | - while ($parent && $parent->exists()) { |
|
| 79 | - $exp .= ' || obj.http.x-url ~ "^'.preg_quote($parent->Link()).'$"'; |
|
| 80 | - $parent = $parent->getParent(); |
|
| 81 | - } |
|
| 82 | - $exp .= ')'; |
|
| 83 | - break; |
|
| 84 | - |
|
| 85 | - case 'all': |
|
| 86 | - $exp = 'obj.http.content-type ~ "'.preg_quote('text/html').'"'; |
|
| 87 | - break; |
|
| 88 | - |
|
| 89 | - case 'everyting': |
|
| 90 | - default: |
|
| 91 | - $exp = 'obj.http.x-url ~ /'; |
|
| 92 | - break; |
|
| 93 | - |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - return static::performFlush($exp); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - return false; |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - protected static function performFlush($banExpression) |
|
| 103 | - { |
|
| 104 | - $success = true; |
|
| 105 | - $urls = static::getUrls(); |
|
| 106 | - // config loaded successfully |
|
| 5 | + private static $flush_on_dev_build = true; |
|
| 6 | + |
|
| 7 | + private static $sitetree_flush_strategy = 'single'; |
|
| 8 | + |
|
| 9 | + private static $api_url = 'https://aperture.section.io/api/v1'; |
|
| 10 | + private static $account_id = ''; |
|
| 11 | + private static $application_id = ''; |
|
| 12 | + private static $environment_name = ''; |
|
| 13 | + private static $proxy_name = ''; |
|
| 14 | + private static $username = ''; |
|
| 15 | + private static $password = ''; |
|
| 16 | + |
|
| 17 | + /** |
|
| 18 | + * Implementation of Flushable::flush() |
|
| 19 | + * Is triggered on dev/build and ?flush=1. |
|
| 20 | + */ |
|
| 21 | + public static function flush() |
|
| 22 | + { |
|
| 23 | + if (Config::inst()->get('SectionIO', 'flush_on_dev_build')) { |
|
| 24 | + return static::flushAll(); |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + return; |
|
| 28 | + } |
|
| 29 | + |
|
| 30 | + public static function flushAll() |
|
| 31 | + { |
|
| 32 | + $exp = 'obj.http.x-url ~ /'; |
|
| 33 | + |
|
| 34 | + return static::performFlush($exp); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + public static function flushImage($imageID) |
|
| 38 | + { |
|
| 39 | + $image = Image::get()->byID($imageID); |
|
| 40 | + if ($image && $image->exists()) { |
|
| 41 | + $exp = 'obj.http.x-url ~ "^/'.preg_quote($image->getFilename()).'$"'; // image itself |
|
| 42 | + $exp .= ' || obj.http.x-url ~ "^/'.preg_quote($image->Parent()->getFilename()) |
|
| 43 | + .'_resampled/(.*)\-'.preg_quote($image->Name).'$"'; // resampled versions |
|
| 44 | + return static::performFlush($exp); |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + return false; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + public static function flushFile($fileID) |
|
| 51 | + { |
|
| 52 | + $file = File::get()->byID($fileID); |
|
| 53 | + if ($file && $file->exists()) { |
|
| 54 | + $exp = 'obj.http.x-url ~ "^/'.preg_quote($file->getFilename()).'$"'; |
|
| 55 | + |
|
| 56 | + return static::performFlush($exp); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + return false; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + public static function flushSiteTree($sitetreeID) |
|
| 63 | + { |
|
| 64 | + $sitetree = SiteTree::get()->byID($sitetreeID); |
|
| 65 | + if ($sitetree && $sitetree->exists()) { |
|
| 66 | + $strategy = Config::inst()->get('SectionIO', 'sitetree_flush_strategy'); |
|
| 67 | + switch ($strategy) { |
|
| 68 | + |
|
| 69 | + case 'single': |
|
| 70 | + $exp = 'obj.http.content-type ~ "'.preg_quote('text/html').'"'; |
|
| 71 | + $exp .= ' && obj.http.x-url ~ "^'.preg_quote($sitetree->Link()).'$"'; |
|
| 72 | + break; |
|
| 73 | + |
|
| 74 | + case 'parents': |
|
| 75 | + $exp = 'obj.http.content-type ~ "'.preg_quote('text/html').'"'; |
|
| 76 | + $exp .= ' && (obj.http.x-url ~ "^'.preg_quote($sitetree->Link()).'$"'; |
|
| 77 | + $parent = $sitetree->getParent(); |
|
| 78 | + while ($parent && $parent->exists()) { |
|
| 79 | + $exp .= ' || obj.http.x-url ~ "^'.preg_quote($parent->Link()).'$"'; |
|
| 80 | + $parent = $parent->getParent(); |
|
| 81 | + } |
|
| 82 | + $exp .= ')'; |
|
| 83 | + break; |
|
| 84 | + |
|
| 85 | + case 'all': |
|
| 86 | + $exp = 'obj.http.content-type ~ "'.preg_quote('text/html').'"'; |
|
| 87 | + break; |
|
| 88 | + |
|
| 89 | + case 'everyting': |
|
| 90 | + default: |
|
| 91 | + $exp = 'obj.http.x-url ~ /'; |
|
| 92 | + break; |
|
| 93 | + |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + return static::performFlush($exp); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + return false; |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + protected static function performFlush($banExpression) |
|
| 103 | + { |
|
| 104 | + $success = true; |
|
| 105 | + $urls = static::getUrls(); |
|
| 106 | + // config loaded successfully |
|
| 107 | 107 | if (static::checkConfig()) { |
| 108 | 108 | if (count($urls) > 0) { |
| 109 | 109 | foreach ($urls as $url) { |
@@ -132,135 +132,135 @@ discard block |
||
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - return $success; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - protected static function getService($url, $banExpression) |
|
| 139 | - { |
|
| 140 | - // prepare API call |
|
| 141 | - $service = new RestfulService( |
|
| 142 | - $url, |
|
| 143 | - 0 // expiry time 0: do not cache the API call |
|
| 144 | - ); |
|
| 145 | - // set basic auth |
|
| 146 | - $username = Config::inst()->get('SectionIO', 'username'); |
|
| 147 | - $password = Config::inst()->get('SectionIO', 'password'); |
|
| 148 | - $service->basicAuth($username, $password); |
|
| 149 | - // set query string (ban expression) |
|
| 150 | - $service->setQueryString(array( |
|
| 151 | - 'banExpression' => $banExpression, |
|
| 152 | - )); |
|
| 153 | - |
|
| 154 | - return $service; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - protected static function getOptions() |
|
| 158 | - { |
|
| 159 | - // prepare curl options for ssl verification |
|
| 160 | - $cert = static::getCertificates(); |
|
| 161 | - $options = array( |
|
| 162 | - CURLOPT_SSL_VERIFYPEER => 1, |
|
| 163 | - CURLOPT_SSL_VERIFYHOST => 2, |
|
| 164 | - CURLOPT_CAINFO => $cert, |
|
| 165 | - ); |
|
| 166 | - |
|
| 167 | - return $options; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - protected static function getCertificates() |
|
| 171 | - { |
|
| 172 | - $cert = ini_get('curl.cainfo'); |
|
| 173 | - if (!$cert) { |
|
| 174 | - $cert = BASE_PATH.'/'.SECTIONIO_BASE.'/cert/cacert.pem'; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - return $cert; |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - protected static function getHeaders() |
|
| 181 | - { |
|
| 182 | - $headers = array( |
|
| 183 | - 'Content-Type: application/json', |
|
| 184 | - 'Accept: application/json', |
|
| 185 | - ); |
|
| 186 | - |
|
| 187 | - return $headers; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - protected static function getUrls() |
|
| 191 | - { |
|
| 192 | - $urls = array(); |
|
| 193 | - |
|
| 194 | - if (static::checkConfig()) { |
|
| 195 | - $api_url = Config::inst()->get('SectionIO', 'api_url'); |
|
| 196 | - $account_id = Config::inst()->get('SectionIO', 'account_id'); |
|
| 197 | - $application_id = Config::inst()->get('SectionIO', 'application_id'); |
|
| 198 | - $application_ids = array(); |
|
| 199 | - if (is_string($application_id)) { |
|
| 200 | - $application_ids = preg_split("/[\s,]+/", $application_id); |
|
| 201 | - } elseif (is_array($application_id)) { |
|
| 202 | - $application_ids = $application_id; |
|
| 203 | - } |
|
| 204 | - $environment_name = Config::inst()->get('SectionIO', 'environment_name'); |
|
| 205 | - $proxy_name = Config::inst()->get('SectionIO', 'proxy_name'); |
|
| 206 | - |
|
| 207 | - foreach ($application_ids as $appid) { |
|
| 208 | - // build API URL: /account/{accountId}/application/{applicationId}/environment/{environmentName}/proxy/{proxyName}/state |
|
| 209 | - $urls[] = Controller::join_links( |
|
| 210 | - $api_url, |
|
| 211 | - 'account', |
|
| 212 | - $account_id, |
|
| 213 | - 'application', |
|
| 214 | - $appid, |
|
| 215 | - 'environment', |
|
| 216 | - $environment_name, |
|
| 217 | - 'proxy', |
|
| 218 | - $proxy_name, |
|
| 219 | - 'state' |
|
| 220 | - ); |
|
| 221 | - } |
|
| 222 | - } |
|
| 223 | - |
|
| 224 | - return $urls; |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - protected static function checkConfig() |
|
| 228 | - { |
|
| 229 | - $missing = array(); |
|
| 230 | - // check config |
|
| 231 | - $api_url = Config::inst()->get('SectionIO', 'api_url'); |
|
| 232 | - if (!isset($api_url) || strlen($api_url) < 1) { |
|
| 233 | - $missing[] = 'SectionIO.api_url'; |
|
| 234 | - } |
|
| 235 | - $account_id = Config::inst()->get('SectionIO', 'account_id'); |
|
| 236 | - if (!isset($account_id) || strlen($account_id) < 1) { |
|
| 237 | - $missing[] = 'SectionIO.account_id'; |
|
| 238 | - } |
|
| 239 | - $application_id = Config::inst()->get('SectionIO', 'application_id'); |
|
| 240 | - if (!isset($application_id) || (!is_array($application_id) && strlen((string) $application_id) < 1)) { |
|
| 241 | - $missing[] = 'SectionIO.application_id'; |
|
| 242 | - } |
|
| 243 | - $environment_name = Config::inst()->get('SectionIO', 'environment_name'); |
|
| 244 | - if (!isset($environment_name) || strlen($environment_name) < 1) { |
|
| 245 | - $missing[] = 'SectionIO.environment_name'; |
|
| 246 | - } |
|
| 247 | - $proxy_name = Config::inst()->get('SectionIO', 'proxy_name'); |
|
| 248 | - if (!isset($proxy_name) || strlen($proxy_name) < 1) { |
|
| 249 | - $missing[] = 'SectionIO.proxy_name'; |
|
| 250 | - } |
|
| 251 | - $username = Config::inst()->get('SectionIO', 'username'); |
|
| 252 | - if (!isset($username) || strlen($username) < 1) { |
|
| 253 | - $missing[] = 'SectionIO.username'; |
|
| 254 | - } |
|
| 255 | - $password = Config::inst()->get('SectionIO', 'password'); |
|
| 256 | - if (!isset($password) || strlen($password) < 1) { |
|
| 257 | - $missing[] = 'SectionIO.password'; |
|
| 258 | - } |
|
| 135 | + return $success; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + protected static function getService($url, $banExpression) |
|
| 139 | + { |
|
| 140 | + // prepare API call |
|
| 141 | + $service = new RestfulService( |
|
| 142 | + $url, |
|
| 143 | + 0 // expiry time 0: do not cache the API call |
|
| 144 | + ); |
|
| 145 | + // set basic auth |
|
| 146 | + $username = Config::inst()->get('SectionIO', 'username'); |
|
| 147 | + $password = Config::inst()->get('SectionIO', 'password'); |
|
| 148 | + $service->basicAuth($username, $password); |
|
| 149 | + // set query string (ban expression) |
|
| 150 | + $service->setQueryString(array( |
|
| 151 | + 'banExpression' => $banExpression, |
|
| 152 | + )); |
|
| 153 | + |
|
| 154 | + return $service; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + protected static function getOptions() |
|
| 158 | + { |
|
| 159 | + // prepare curl options for ssl verification |
|
| 160 | + $cert = static::getCertificates(); |
|
| 161 | + $options = array( |
|
| 162 | + CURLOPT_SSL_VERIFYPEER => 1, |
|
| 163 | + CURLOPT_SSL_VERIFYHOST => 2, |
|
| 164 | + CURLOPT_CAINFO => $cert, |
|
| 165 | + ); |
|
| 166 | + |
|
| 167 | + return $options; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + protected static function getCertificates() |
|
| 171 | + { |
|
| 172 | + $cert = ini_get('curl.cainfo'); |
|
| 173 | + if (!$cert) { |
|
| 174 | + $cert = BASE_PATH.'/'.SECTIONIO_BASE.'/cert/cacert.pem'; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + return $cert; |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + protected static function getHeaders() |
|
| 181 | + { |
|
| 182 | + $headers = array( |
|
| 183 | + 'Content-Type: application/json', |
|
| 184 | + 'Accept: application/json', |
|
| 185 | + ); |
|
| 186 | + |
|
| 187 | + return $headers; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + protected static function getUrls() |
|
| 191 | + { |
|
| 192 | + $urls = array(); |
|
| 193 | + |
|
| 194 | + if (static::checkConfig()) { |
|
| 195 | + $api_url = Config::inst()->get('SectionIO', 'api_url'); |
|
| 196 | + $account_id = Config::inst()->get('SectionIO', 'account_id'); |
|
| 197 | + $application_id = Config::inst()->get('SectionIO', 'application_id'); |
|
| 198 | + $application_ids = array(); |
|
| 199 | + if (is_string($application_id)) { |
|
| 200 | + $application_ids = preg_split("/[\s,]+/", $application_id); |
|
| 201 | + } elseif (is_array($application_id)) { |
|
| 202 | + $application_ids = $application_id; |
|
| 203 | + } |
|
| 204 | + $environment_name = Config::inst()->get('SectionIO', 'environment_name'); |
|
| 205 | + $proxy_name = Config::inst()->get('SectionIO', 'proxy_name'); |
|
| 206 | + |
|
| 207 | + foreach ($application_ids as $appid) { |
|
| 208 | + // build API URL: /account/{accountId}/application/{applicationId}/environment/{environmentName}/proxy/{proxyName}/state |
|
| 209 | + $urls[] = Controller::join_links( |
|
| 210 | + $api_url, |
|
| 211 | + 'account', |
|
| 212 | + $account_id, |
|
| 213 | + 'application', |
|
| 214 | + $appid, |
|
| 215 | + 'environment', |
|
| 216 | + $environment_name, |
|
| 217 | + 'proxy', |
|
| 218 | + $proxy_name, |
|
| 219 | + 'state' |
|
| 220 | + ); |
|
| 221 | + } |
|
| 222 | + } |
|
| 223 | + |
|
| 224 | + return $urls; |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + protected static function checkConfig() |
|
| 228 | + { |
|
| 229 | + $missing = array(); |
|
| 230 | + // check config |
|
| 231 | + $api_url = Config::inst()->get('SectionIO', 'api_url'); |
|
| 232 | + if (!isset($api_url) || strlen($api_url) < 1) { |
|
| 233 | + $missing[] = 'SectionIO.api_url'; |
|
| 234 | + } |
|
| 235 | + $account_id = Config::inst()->get('SectionIO', 'account_id'); |
|
| 236 | + if (!isset($account_id) || strlen($account_id) < 1) { |
|
| 237 | + $missing[] = 'SectionIO.account_id'; |
|
| 238 | + } |
|
| 239 | + $application_id = Config::inst()->get('SectionIO', 'application_id'); |
|
| 240 | + if (!isset($application_id) || (!is_array($application_id) && strlen((string) $application_id) < 1)) { |
|
| 241 | + $missing[] = 'SectionIO.application_id'; |
|
| 242 | + } |
|
| 243 | + $environment_name = Config::inst()->get('SectionIO', 'environment_name'); |
|
| 244 | + if (!isset($environment_name) || strlen($environment_name) < 1) { |
|
| 245 | + $missing[] = 'SectionIO.environment_name'; |
|
| 246 | + } |
|
| 247 | + $proxy_name = Config::inst()->get('SectionIO', 'proxy_name'); |
|
| 248 | + if (!isset($proxy_name) || strlen($proxy_name) < 1) { |
|
| 249 | + $missing[] = 'SectionIO.proxy_name'; |
|
| 250 | + } |
|
| 251 | + $username = Config::inst()->get('SectionIO', 'username'); |
|
| 252 | + if (!isset($username) || strlen($username) < 1) { |
|
| 253 | + $missing[] = 'SectionIO.username'; |
|
| 254 | + } |
|
| 255 | + $password = Config::inst()->get('SectionIO', 'password'); |
|
| 256 | + if (!isset($password) || strlen($password) < 1) { |
|
| 257 | + $missing[] = 'SectionIO.password'; |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | - if (count($missing) > 0) { |
|
| 261 | - SS_Log::log('SectionIO:: config parameters mising: ' . implode(', ', $missing), SS_Log::WARN); |
|
| 262 | - return false; |
|
| 263 | - } |
|
| 264 | - return true; |
|
| 265 | - } |
|
| 260 | + if (count($missing) > 0) { |
|
| 261 | + SS_Log::log('SectionIO:: config parameters mising: ' . implode(', ', $missing), SS_Log::WARN); |
|
| 262 | + return false; |
|
| 263 | + } |
|
| 264 | + return true; |
|
| 265 | + } |
|
| 266 | 266 | } |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $image = Image::get()->byID($imageID); |
| 40 | 40 | if ($image && $image->exists()) { |
| 41 | - $exp = 'obj.http.x-url ~ "^/'.preg_quote($image->getFilename()).'$"'; // image itself |
|
| 42 | - $exp .= ' || obj.http.x-url ~ "^/'.preg_quote($image->Parent()->getFilename()) |
|
| 43 | - .'_resampled/(.*)\-'.preg_quote($image->Name).'$"'; // resampled versions |
|
| 41 | + $exp = 'obj.http.x-url ~ "^/' . preg_quote($image->getFilename()) . '$"'; // image itself |
|
| 42 | + $exp .= ' || obj.http.x-url ~ "^/' . preg_quote($image->Parent()->getFilename()) |
|
| 43 | + .'_resampled/(.*)\-' . preg_quote($image->Name) . '$"'; // resampled versions |
|
| 44 | 44 | return static::performFlush($exp); |
| 45 | 45 | } |
| 46 | 46 | |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | { |
| 52 | 52 | $file = File::get()->byID($fileID); |
| 53 | 53 | if ($file && $file->exists()) { |
| 54 | - $exp = 'obj.http.x-url ~ "^/'.preg_quote($file->getFilename()).'$"'; |
|
| 54 | + $exp = 'obj.http.x-url ~ "^/' . preg_quote($file->getFilename()) . '$"'; |
|
| 55 | 55 | |
| 56 | 56 | return static::performFlush($exp); |
| 57 | 57 | } |
@@ -67,23 +67,23 @@ discard block |
||
| 67 | 67 | switch ($strategy) { |
| 68 | 68 | |
| 69 | 69 | case 'single': |
| 70 | - $exp = 'obj.http.content-type ~ "'.preg_quote('text/html').'"'; |
|
| 71 | - $exp .= ' && obj.http.x-url ~ "^'.preg_quote($sitetree->Link()).'$"'; |
|
| 70 | + $exp = 'obj.http.content-type ~ "' . preg_quote('text/html') . '"'; |
|
| 71 | + $exp .= ' && obj.http.x-url ~ "^' . preg_quote($sitetree->Link()) . '$"'; |
|
| 72 | 72 | break; |
| 73 | 73 | |
| 74 | 74 | case 'parents': |
| 75 | - $exp = 'obj.http.content-type ~ "'.preg_quote('text/html').'"'; |
|
| 76 | - $exp .= ' && (obj.http.x-url ~ "^'.preg_quote($sitetree->Link()).'$"'; |
|
| 75 | + $exp = 'obj.http.content-type ~ "' . preg_quote('text/html') . '"'; |
|
| 76 | + $exp .= ' && (obj.http.x-url ~ "^' . preg_quote($sitetree->Link()) . '$"'; |
|
| 77 | 77 | $parent = $sitetree->getParent(); |
| 78 | 78 | while ($parent && $parent->exists()) { |
| 79 | - $exp .= ' || obj.http.x-url ~ "^'.preg_quote($parent->Link()).'$"'; |
|
| 79 | + $exp .= ' || obj.http.x-url ~ "^' . preg_quote($parent->Link()) . '$"'; |
|
| 80 | 80 | $parent = $parent->getParent(); |
| 81 | 81 | } |
| 82 | 82 | $exp .= ')'; |
| 83 | 83 | break; |
| 84 | 84 | |
| 85 | 85 | case 'all': |
| 86 | - $exp = 'obj.http.content-type ~ "'.preg_quote('text/html').'"'; |
|
| 86 | + $exp = 'obj.http.content-type ~ "' . preg_quote('text/html') . '"'; |
|
| 87 | 87 | break; |
| 88 | 88 | |
| 89 | 89 | case 'everyting': |
@@ -121,10 +121,10 @@ discard block |
||
| 121 | 121 | $conn = $service->request(null, 'POST', null, $headers, $options); |
| 122 | 122 | |
| 123 | 123 | if ($conn->isError()) { |
| 124 | - SS_Log::log('SectionIO::performFlush :: '.$conn->getStatusCode().' : '.$conn->getStatusDescription().' : '.$url, SS_Log::ERR); |
|
| 124 | + SS_Log::log('SectionIO::performFlush :: ' . $conn->getStatusCode() . ' : ' . $conn->getStatusDescription() . ' : ' . $url, SS_Log::ERR); |
|
| 125 | 125 | $success = $success && false; |
| 126 | 126 | } else { |
| 127 | - SS_Log::log('SectionIO::performFlush :: ban successful. url: '.$url."; ban expression: '".$banExpression."'", SS_Log::NOTICE); |
|
| 127 | + SS_Log::log('SectionIO::performFlush :: ban successful. url: ' . $url . "; ban expression: '" . $banExpression . "'", SS_Log::NOTICE); |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | } else { |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | { |
| 172 | 172 | $cert = ini_get('curl.cainfo'); |
| 173 | 173 | if (!$cert) { |
| 174 | - $cert = BASE_PATH.'/'.SECTIONIO_BASE.'/cert/cacert.pem'; |
|
| 174 | + $cert = BASE_PATH . '/' . SECTIONIO_BASE . '/cert/cacert.pem'; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | return $cert; |