@@ -48,7 +48,7 @@ |
||
| 48 | 48 | return ($aOrder < $bOrder) ? -1 : 1; |
| 49 | 49 | }); |
| 50 | 50 | $array['actions'] = []; |
| 51 | - foreach($this->actions as $action) { |
|
| 51 | + foreach ($this->actions as $action) { |
|
| 52 | 52 | $array['actions'][] = $action->__toArray(); |
| 53 | 53 | } |
| 54 | 54 | return $array; |
@@ -39,8 +39,8 @@ |
||
| 39 | 39 | "domain" => $this->getDomain(), |
| 40 | 40 | "listLabel" => Api::API_LIST_NAME_FIELD, |
| 41 | 41 | 'modelId' => Api::API_MODEL_KEY_FIELD, |
| 42 | - 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-' . $this->getDomain() . '-' . $this->getApi()), TRUE)), |
|
| 43 | - "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain() . '-' . 'api-' . $this->getApi() . "-pk"), TRUE)), |
|
| 42 | + 'formUrl' => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower('admin-api-form-'.$this->getDomain().'-'.$this->getApi()), TRUE)), |
|
| 43 | + "url" => preg_replace('/\/\{(.*)\}$/i', '', $this->getRoute(strtolower($this->getDomain().'-'.'api-'.$this->getApi()."-pk"), TRUE)), |
|
| 44 | 44 | ), [], ''); |
| 45 | 45 | } |
| 46 | 46 | |
@@ -41,11 +41,11 @@ discard block |
||
| 41 | 41 | public function render($template, array $vars = array(), $cookies = array(), $domain = null) |
| 42 | 42 | { |
| 43 | 43 | $vars['__menu__'] = $this->getMenu(); |
| 44 | - if(Config::getParam('profiling.enable')) { |
|
| 44 | + if (Config::getParam('profiling.enable')) { |
|
| 45 | 45 | $vars['__profiling__'] = Inspector::getStats(); |
| 46 | 46 | } |
| 47 | 47 | $domain = (null === $domain) ? $this->getDomain() : $domain; |
| 48 | - return $this->tpl->render($domain . $template, $vars, $cookies); |
|
| 48 | + return $this->tpl->render($domain.$template, $vars, $cookies); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | { |
| 77 | 77 | $vars['__menu__'] = $this->getMenu(); |
| 78 | 78 | $domain = $domain ?: $this->getDomain(); |
| 79 | - return $this->tpl->dump($domain . $template, $vars); |
|
| 79 | + return $this->tpl->dump($domain.$template, $vars); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -82,9 +82,9 @@ |
||
| 82 | 82 | "class" => "btn-warning md-default", |
| 83 | 83 | "icon" => "fa-plus", |
| 84 | 84 | ]; |
| 85 | - if(Config::getParam('admin.version', 'v1') === 'v1') { |
|
| 86 | - $add["onclick"] = "javascript:addNewField(document.getElementById('" . $this->getName() . "'));"; |
|
| 87 | - } else { |
|
| 85 | + if (Config::getParam('admin.version', 'v1') === 'v1') { |
|
| 86 | + $add["onclick"] = "javascript:addNewField(document.getElementById('".$this->getName()."'));"; |
|
| 87 | + }else { |
|
| 88 | 88 | $add["ng-click"] = "addNewField()"; |
| 89 | 89 | } |
| 90 | 90 | $this->addButton('submit', _("Guardar configuración"), "submit", array( |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | $this->setStatusCode(Template::STATUS_OK); |
| 121 | 121 | break; |
| 122 | 122 | default: |
| 123 | - $this->setStatusCode('HTTP/1.0 ' . $status ?: 200); |
|
| 123 | + $this->setStatusCode('HTTP/1.0 '.$status ?: 200); |
|
| 124 | 124 | break; |
| 125 | 125 | } |
| 126 | 126 | return $this; |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | ResponseHelper::setStatusHeader($this->getStatusCode()); |
| 139 | 139 | ResponseHelper::setAuthHeaders($this->isPublicZone()); |
| 140 | 140 | ResponseHelper::setCookieHeaders($cookies); |
| 141 | - header('Content-type: ' . $contentType); |
|
| 141 | + header('Content-type: '.$contentType); |
|
| 142 | 142 | |
| 143 | 143 | } |
| 144 | 144 | |
@@ -154,16 +154,16 @@ discard block |
||
| 154 | 154 | Logger::log('Start output response'); |
| 155 | 155 | ob_start(); |
| 156 | 156 | $this->setReponseHeaders($contentType, $cookies); |
| 157 | - header('Content-length: ' . strlen($output)); |
|
| 158 | - header('CRC: ' . crc32($output)); |
|
| 157 | + header('Content-length: '.strlen($output)); |
|
| 158 | + header('CRC: '.crc32($output)); |
|
| 159 | 159 | |
| 160 | 160 | $needCache = Cache::needCache(); |
| 161 | 161 | $cache = Cache::getInstance(); |
| 162 | 162 | list($path, $cacheDataName) = $cache->getRequestCacheHash(); |
| 163 | 163 | if (false !== $needCache && $this->getStatusCode() === Template::STATUS_OK && null !== $cacheDataName) { |
| 164 | 164 | Logger::log('Saving output response into cache'); |
| 165 | - $cache->storeData("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName, $output); |
|
| 166 | - $cache->storeData("json" . DIRECTORY_SEPARATOR . $path . $cacheDataName . ".headers", headers_list(), Cache::JSON); |
|
| 165 | + $cache->storeData("json".DIRECTORY_SEPARATOR.$path.$cacheDataName, $output); |
|
| 166 | + $cache->storeData("json".DIRECTORY_SEPARATOR.$path.$cacheDataName.".headers", headers_list(), Cache::JSON); |
|
| 167 | 167 | } elseif (Request::getInstance()->getMethod() !== 'GET') { |
| 168 | 168 | $cache->flushCache(); |
| 169 | 169 | } |
@@ -183,11 +183,11 @@ discard block |
||
| 183 | 183 | Logger::log('Close template render'); |
| 184 | 184 | $uri = Request::requestUri(); |
| 185 | 185 | Security::getInstance()->setSessionKey("lastRequest", array( |
| 186 | - "url" => Request::getInstance()->getRootUrl() . $uri, |
|
| 186 | + "url" => Request::getInstance()->getRootUrl().$uri, |
|
| 187 | 187 | "ts" => microtime(true), |
| 188 | 188 | )); |
| 189 | 189 | Security::getInstance()->updateSession(); |
| 190 | - Logger::log('End request: ' . $uri, LOG_INFO); |
|
| 190 | + Logger::log('End request: '.$uri, LOG_INFO); |
|
| 191 | 191 | exit; |
| 192 | 192 | } |
| 193 | 193 | |
@@ -225,17 +225,17 @@ discard block |
||
| 225 | 225 | ///////////////////////////////////////////////////////////// |
| 226 | 226 | // Date in the past sets the value to already have been expired. |
| 227 | 227 | header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); |
| 228 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
| 228 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
| 229 | 229 | header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 |
| 230 | 230 | header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 |
| 231 | 231 | header("Pragma: no-cache"); |
| 232 | 232 | header("Expires: 0"); |
| 233 | 233 | header('Content-Transfer-Encoding: binary'); |
| 234 | - header("Content-type: " . $content); |
|
| 235 | - header("Content-length: " . strlen($data)); |
|
| 236 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
| 234 | + header("Content-type: ".$content); |
|
| 235 | + header("Content-length: ".strlen($data)); |
|
| 236 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
| 237 | 237 | header("Access-Control-Expose-Headers: Filename"); |
| 238 | - header("Filename: " . $filename); |
|
| 238 | + header("Filename: ".$filename); |
|
| 239 | 239 | echo $data; |
| 240 | 240 | ob_flush(); |
| 241 | 241 | ob_end_clean(); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | protected static function calculateStats(array $stats, $ts, $mem = 0, $files = 0) { |
| 29 | 29 | return [ |
| 30 | 30 | 'ts' => round($stats['ts'] - $ts, 4), |
| 31 | - 'mem' => round(($stats['mem'] - $mem) / 1024 / 1024, 4), |
|
| 31 | + 'mem' => round(($stats['mem'] - $mem)/1024/1024, 4), |
|
| 32 | 32 | 'files' => $stats['files'] - $files, |
| 33 | 33 | 'name' => $stats['name'], |
| 34 | 34 | ]; |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $ts = defined('PSFS_START_TS') ? PSFS_START_TS : 0; |
| 43 | 43 | $mem = defined('PSFS_START_MEM') ? PSFS_START_MEM : 0; |
| 44 | 44 | $files = 0; |
| 45 | - foreach(self::$profiling as $key => &$value) { |
|
| 45 | + foreach (self::$profiling as $key => &$value) { |
|
| 46 | 46 | $value = self::calculateStats($value, $ts, $mem, $files); |
| 47 | 47 | } |
| 48 | 48 | self::$profiling[] = self::calculateStats(self::collect('Profiling collect ends'), $ts, $mem, $files); |
@@ -73,18 +73,18 @@ |
||
| 73 | 73 | if (!Request::getInstance()->isFile()) { |
| 74 | 74 | return $this->router->execute($this->actualUri); |
| 75 | 75 | } |
| 76 | - } else { |
|
| 76 | + }else { |
|
| 77 | 77 | return ConfigController::getInstance()->config(); |
| 78 | 78 | } |
| 79 | - } catch (AdminCredentialsException $a) { |
|
| 79 | + }catch (AdminCredentialsException $a) { |
|
| 80 | 80 | return UserController::showAdminManager(); |
| 81 | - } catch (SecurityException $s) { |
|
| 81 | + }catch (SecurityException $s) { |
|
| 82 | 82 | return $this->security->notAuthorized($this->actualUri); |
| 83 | - } catch (RouterException $r) { |
|
| 83 | + }catch (RouterException $r) { |
|
| 84 | 84 | return $this->router->httpNotFound($r); |
| 85 | - } catch(ApiException $a) { |
|
| 85 | + }catch (ApiException $a) { |
|
| 86 | 86 | return $this->router->httpNotFound($a, true); |
| 87 | - } catch (\Exception $e) { |
|
| 87 | + }catch (\Exception $e) { |
|
| 88 | 88 | return $this->dumpException($e); |
| 89 | 89 | } |
| 90 | 90 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | public function __construct($hydrate = true) |
| 19 | 19 | { |
| 20 | 20 | parent::__construct(); |
| 21 | - if($hydrate) { |
|
| 21 | + if ($hydrate) { |
|
| 22 | 22 | $this->fromArray(Request::getInstance()->getData()); |
| 23 | 23 | } |
| 24 | 24 | } |
@@ -46,15 +46,15 @@ discard block |
||
| 46 | 46 | /** @var \ReflectionProperty $property */ |
| 47 | 47 | foreach ($properties as $property) { |
| 48 | 48 | $value = $property->getValue($this); |
| 49 | - if(is_object($value) && method_exists($value, 'toArray')) { |
|
| 49 | + if (is_object($value) && method_exists($value, 'toArray')) { |
|
| 50 | 50 | $dto[$property->getName()] = $value->toArray(); |
| 51 | - } else { |
|
| 51 | + }else { |
|
| 52 | 52 | $dto[$property->getName()] = $property->getValue($this); |
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | - } catch (\Exception $e) { |
|
| 57 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
| 56 | + }catch (\Exception $e) { |
|
| 57 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
| 58 | 58 | } |
| 59 | 59 | return $dto; |
| 60 | 60 | } |
@@ -76,32 +76,32 @@ discard block |
||
| 76 | 76 | protected function parseDtoField(array $properties, $key, $value = null) { |
| 77 | 77 | $type = 'string'; |
| 78 | 78 | $is_array = false; |
| 79 | - if(array_key_exists($key, $properties)) { |
|
| 79 | + if (array_key_exists($key, $properties)) { |
|
| 80 | 80 | $type = $properties[$key]; |
| 81 | - if(preg_match('/(\[\]|Array)/i', $type)) { |
|
| 81 | + if (preg_match('/(\[\]|Array)/i', $type)) { |
|
| 82 | 82 | $type = preg_replace('/(\[\]|Array)/i', '', $type); |
| 83 | 83 | $is_array = true; |
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | $reflector = (class_exists($type)) ? new \ReflectionClass($type) : null; |
| 87 | - if(null !== $reflector && $reflector->isSubclassOf(Dto::class)) { |
|
| 88 | - if(null !== $value && is_array($value)) { |
|
| 89 | - if($is_array) { |
|
| 87 | + if (null !== $reflector && $reflector->isSubclassOf(Dto::class)) { |
|
| 88 | + if (null !== $value && is_array($value)) { |
|
| 89 | + if ($is_array) { |
|
| 90 | 90 | $this->$key = []; |
| 91 | - foreach($value as $data) { |
|
| 92 | - if(null !== $data && is_array($data)) { |
|
| 91 | + foreach ($value as $data) { |
|
| 92 | + if (null !== $data && is_array($data)) { |
|
| 93 | 93 | $dto = new $type(false); |
| 94 | 94 | $dto->fromArray($data); |
| 95 | 95 | array_push($this->$key, $dto); |
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | - } else { |
|
| 98 | + }else { |
|
| 99 | 99 | $this->$key = new $type(false); |
| 100 | 100 | $this->$key->fromArray($value); |
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | - } else { |
|
| 104 | - switch($type) { |
|
| 103 | + }else { |
|
| 104 | + switch ($type) { |
|
| 105 | 105 | default: |
| 106 | 106 | case 'string': |
| 107 | 107 | $this->$key = $value; |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | if (!Config::getInstance()->checkTryToSaveConfig() |
| 30 | 30 | && (preg_match('/^\/(admin|setup\-admin)/i', $route) || Config::getParam('restricted', false)) |
| 31 | 31 | ) { |
| 32 | - if (null === Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true)) { |
|
| 32 | + if (null === Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true)) { |
|
| 33 | 33 | throw new AdminCredentialsException(); |
| 34 | 34 | } |
| 35 | 35 | if (!Security::getInstance()->checkAdmin()) { |
@@ -49,8 +49,8 @@ discard block |
||
| 49 | 49 | $token = ''; |
| 50 | 50 | $ct = strlen($ts); |
| 51 | 51 | for ($i = 0; $i < $ct; $i++) { |
| 52 | - $token = substr($hash, $i, 1) . |
|
| 53 | - substr($ts, $i, 1) . |
|
| 52 | + $token = substr($hash, $i, 1). |
|
| 53 | + substr($ts, $i, 1). |
|
| 54 | 54 | $token; |
| 55 | 55 | } |
| 56 | 56 | return $token; |
@@ -68,16 +68,16 @@ discard block |
||
| 68 | 68 | $charsLength = strlen(self::RAND_SEP) - 1; |
| 69 | 69 | $tsLength = strlen($ts); |
| 70 | 70 | $i = 0; |
| 71 | - $ct = ceil($hashRest / 4); |
|
| 72 | - $part = substr($hash, $tsLength + $ct * $i, $ct); |
|
| 73 | - while(false !== $part) { |
|
| 74 | - $mixedToken .= $part . |
|
| 75 | - substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1) . |
|
| 71 | + $ct = ceil($hashRest/4); |
|
| 72 | + $part = substr($hash, $tsLength + $ct*$i, $ct); |
|
| 73 | + while (false !== $part) { |
|
| 74 | + $mixedToken .= $part. |
|
| 75 | + substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1). |
|
| 76 | 76 | substr(self::RAND_SEP, round(rand(0, $charsLength), 0, PHP_ROUND_HALF_DOWN), 1); |
| 77 | - $part = substr($hash, $tsLength + $ct * $i, $ct); |
|
| 77 | + $part = substr($hash, $tsLength + $ct*$i, $ct); |
|
| 78 | 78 | $i++; |
| 79 | 79 | } |
| 80 | - return $mixedToken . $token; |
|
| 80 | + return $mixedToken.$token; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -86,10 +86,10 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | private static function getTs($isOdd = null) { |
| 88 | 88 | $ts = time(); |
| 89 | - $tsIsOdd = (bool)((int)substr($ts, -1) % 2); |
|
| 90 | - if(false === $isOdd && !$tsIsOdd) { |
|
| 89 | + $tsIsOdd = (bool)((int)substr($ts, -1)%2); |
|
| 90 | + if (false === $isOdd && !$tsIsOdd) { |
|
| 91 | 91 | $ts--; |
| 92 | - } elseif(true === $isOdd && !$tsIsOdd) { |
|
| 92 | + } elseif (true === $isOdd && !$tsIsOdd) { |
|
| 93 | 93 | $ts--; |
| 94 | 94 | } |
| 95 | 95 | return $ts; |
@@ -121,10 +121,10 @@ discard block |
||
| 121 | 121 | $partToken = ''; |
| 122 | 122 | $ts = ''; |
| 123 | 123 | $part = strrev($part); |
| 124 | - for($i = 0, $ct = strlen($part); $i < $ct; $i++) { |
|
| 125 | - if($i % 2 == 0) { |
|
| 124 | + for ($i = 0, $ct = strlen($part); $i < $ct; $i++) { |
|
| 125 | + if ($i%2 == 0) { |
|
| 126 | 126 | $ts .= substr($part, $i, 1); |
| 127 | - } else { |
|
| 127 | + }else { |
|
| 128 | 128 | $partToken .= substr($part, $i, 1); |
| 129 | 129 | } |
| 130 | 130 | } |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | private static function parseTokenParts(array $parts) { |
| 140 | 140 | $token = ''; |
| 141 | 141 | list($partToken, $ts) = self::extractTs(array_pop($parts)); |
| 142 | - if($ts > 0) { |
|
| 143 | - foreach($parts as $part) { |
|
| 142 | + if ($ts > 0) { |
|
| 143 | + foreach ($parts as $part) { |
|
| 144 | 144 | $token .= $part; |
| 145 | 145 | } |
| 146 | - $token = $partToken . $token; |
|
| 146 | + $token = $partToken.$token; |
|
| 147 | 147 | } |
| 148 | 148 | return [$token, $ts]; |
| 149 | 149 | } |
@@ -171,8 +171,8 @@ discard block |
||
| 171 | 171 | * @return array |
| 172 | 172 | */ |
| 173 | 173 | private static function extractTokenParts($token) { |
| 174 | - for($i = 0, $ct = strlen(self::RAND_SEP); $i < $ct; $i++) { |
|
| 175 | - $token = str_replace(substr(self::RAND_SEP,$i,1), "|", $token); |
|
| 174 | + for ($i = 0, $ct = strlen(self::RAND_SEP); $i < $ct; $i++) { |
|
| 175 | + $token = str_replace(substr(self::RAND_SEP, $i, 1), "|", $token); |
|
| 176 | 176 | } |
| 177 | 177 | return array_unique(explode('||', $token)); |
| 178 | 178 | } |