@@ -120,13 +120,13 @@ discard block |
||
| 120 | 120 | public static function save($user) |
| 121 | 121 | { |
| 122 | 122 | $admins = array(); |
| 123 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
| 124 | - $admins = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json'), TRUE); |
|
| 123 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
| 124 | + $admins = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json'), TRUE); |
|
| 125 | 125 | } |
| 126 | - $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']); |
|
| 126 | + $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']); |
|
| 127 | 127 | $admins[$user['username']]['profile'] = $user['profile']; |
| 128 | 128 | |
| 129 | - return (FALSE !== file_put_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', json_encode($admins, JSON_PRETTY_PRINT))); |
|
| 129 | + return (FALSE !== file_put_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', json_encode($admins, JSON_PRETTY_PRINT))); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | public function getAdmins() |
| 161 | 161 | { |
| 162 | 162 | $admins = array(); |
| 163 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
| 164 | - $admins = json_decode(file_get_contents(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json'), TRUE); |
|
| 163 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
| 164 | + $admins = json_decode(file_get_contents(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json'), TRUE); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | return $admins; |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | { |
| 181 | 181 | Logger::log('Checking admin session'); |
| 182 | 182 | if (!$this->authorized && !$this->checked) { |
| 183 | - if (file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
| 183 | + if (file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
| 184 | 184 | $request = Request::getInstance(); |
| 185 | 185 | $admins = $this->getAdmins(); |
| 186 | 186 | //Sacamos las credenciales de la petición |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | } |
| 192 | 192 | if (!empty($user) && !empty($admins[$user])) { |
| 193 | 193 | $auth = $admins[$user]['hash']; |
| 194 | - $this->authorized = ($auth == sha1($user . $pass)); |
|
| 194 | + $this->authorized = ($auth == sha1($user.$pass)); |
|
| 195 | 195 | if ($this->authorized) { |
| 196 | 196 | $this->admin = array( |
| 197 | 197 | 'alias' => $user, |
@@ -417,12 +417,12 @@ discard block |
||
| 417 | 417 | $axis = 0; |
| 418 | 418 | $parts = array(); |
| 419 | 419 | try { |
| 420 | - $partLength = floor(strlen($token) / 10); |
|
| 421 | - for ($i = 0, $ct = ceil(strlen($token) / $partLength); $i < $ct; $i++) { |
|
| 420 | + $partLength = floor(strlen($token)/10); |
|
| 421 | + for ($i = 0, $ct = ceil(strlen($token)/$partLength); $i < $ct; $i++) { |
|
| 422 | 422 | $parts[] = substr($token, $axis, $partLength); |
| 423 | 423 | $axis += $partLength; |
| 424 | 424 | } |
| 425 | - } catch (\Exception $e) { |
|
| 425 | + }catch (\Exception $e) { |
|
| 426 | 426 | $partLength = 0; |
| 427 | 427 | } |
| 428 | 428 | |
@@ -462,7 +462,7 @@ discard block |
||
| 462 | 462 | $decoded = NULL; |
| 463 | 463 | list($partLength, $parts) = self::extractTokenParts($token); |
| 464 | 464 | list($ts, $mod) = self::extractTsAndMod($parts, $partLength); |
| 465 | - $hashMod = substr(strtoupper(sha1($module)), strlen($ts) / 2, strlen($ts) * 2); |
|
| 465 | + $hashMod = substr(strtoupper(sha1($module)), strlen($ts)/2, strlen($ts)*2); |
|
| 466 | 466 | if (time() - (integer)$ts < 300 && $hashMod === $mod) { |
| 467 | 467 | $decoded = implode('', $parts); |
| 468 | 468 | } |
@@ -479,16 +479,16 @@ discard block |
||
| 479 | 479 | public static function generateToken($secret, $module = 'PSFS') |
| 480 | 480 | { |
| 481 | 481 | $ts = time(); |
| 482 | - $hashModule = substr(strtoupper(sha1($module)), strlen($ts) / 2, strlen($ts) * 2); |
|
| 482 | + $hashModule = substr(strtoupper(sha1($module)), strlen($ts)/2, strlen($ts)*2); |
|
| 483 | 483 | $hash = hash('sha256', $secret); |
| 484 | - $insert = floor(strlen($hash) / strlen($ts)); |
|
| 484 | + $insert = floor(strlen($hash)/strlen($ts)); |
|
| 485 | 485 | $j = 0; |
| 486 | 486 | $token = ''; |
| 487 | 487 | for ($i = 0, $ct = strlen($ts); $i < $ct; $i++) { |
| 488 | - $token .= substr($ts, $i, 1) . substr($hash, $j, $insert) . substr($hashModule, $i, 2); |
|
| 488 | + $token .= substr($ts, $i, 1).substr($hash, $j, $insert).substr($hashModule, $i, 2); |
|
| 489 | 489 | $j += $insert; |
| 490 | 490 | } |
| 491 | - $token .= substr($hash, ($insert * strlen($ts)), strlen($hash) - ($insert * strlen($ts))); |
|
| 491 | + $token .= substr($hash, ($insert*strlen($ts)), strlen($hash) - ($insert*strlen($ts))); |
|
| 492 | 492 | return $token; |
| 493 | 493 | } |
| 494 | 494 | |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | )) |
| 38 | 38 | ->addButton('submit', _("Acceder como {{username}}")) |
| 39 | 39 | ->addButton("cancel", _("Cancelar"), "button", array( |
| 40 | - "onclick" => "javacript:location.href = \"" . Router::getInstance()->getRoute('') . "\";", |
|
| 40 | + "onclick" => "javacript:location.href = \"".Router::getInstance()->getRoute('')."\";", |
|
| 41 | 41 | "class" => "btn-link", |
| 42 | 42 | )); |
| 43 | 43 | } |
@@ -78,7 +78,7 @@ |
||
| 78 | 78 | "class" => "btn-success col-md-offset-2" |
| 79 | 79 | )) |
| 80 | 80 | ->addButton('add_field', _('Añadir nuevo parámetro'), 'button', array( |
| 81 | - "onclick" => "javascript:addNewField(document.getElementById('" . $this->getName() . "'));", |
|
| 81 | + "onclick" => "javascript:addNewField(document.getElementById('".$this->getName()."'));", |
|
| 82 | 82 | "class" => "btn-warning", |
| 83 | 83 | )); |
| 84 | 84 | } |
@@ -36,8 +36,8 @@ |
||
| 36 | 36 | $dto[$property->getName()] = $property->getValue($this); |
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | - } catch (\Exception $e) { |
|
| 40 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
| 39 | + }catch (\Exception $e) { |
|
| 40 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
| 41 | 41 | } |
| 42 | 42 | return $dto; |
| 43 | 43 | } |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | { |
| 63 | 63 | if (preg_match('/^asc$/i', $direction)) { |
| 64 | 64 | return Order::ASC; |
| 65 | - } else { |
|
| 65 | + }else { |
|
| 66 | 66 | return Order::DESC; |
| 67 | 67 | } |
| 68 | 68 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | $vars['__menu__'] = $this->getMenu(); |
| 38 | 38 | $domain = (null === $domain) ? $this->getDomain() : $domain; |
| 39 | - return $this->tpl->render($domain . $template, $vars, $cookies); |
|
| 39 | + return $this->tpl->render($domain.$template, $vars, $cookies); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | { |
| 68 | 68 | $vars['__menu__'] = $this->getMenu(); |
| 69 | 69 | $domain = $domain ?: $this->getDomain(); |
| 70 | - return $this->tpl->dump($domain . $template, $vars); |
|
| 70 | + return $this->tpl->dump($domain.$template, $vars); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -96,15 +96,15 @@ discard block |
||
| 96 | 96 | ///////////////////////////////////////////////////////////// |
| 97 | 97 | // Date in the past sets the value to already have been expired. |
| 98 | 98 | header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); |
| 99 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
| 99 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
| 100 | 100 | header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 |
| 101 | 101 | header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 |
| 102 | 102 | header("Pragma: no-cache"); |
| 103 | 103 | header("Expires: 0"); |
| 104 | 104 | header('Content-Transfer-Encoding: none'); |
| 105 | - header("Content-type: " . $content); |
|
| 106 | - header("Content-length: " . strlen($data)); |
|
| 107 | - header('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
| 105 | + header("Content-type: ".$content); |
|
| 106 | + header("Content-length: ".strlen($data)); |
|
| 107 | + header('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
| 108 | 108 | echo $data; |
| 109 | 109 | ob_flush(); |
| 110 | 110 | ob_end_clean(); |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | public static function getClassToCall($action) |
| 23 | 23 | { |
| 24 | 24 | Logger::log('Getting class to call for executing the request action', LOG_DEBUG, $action); |
| 25 | - $actionClass = class_exists($action["class"]) ? $action["class"] : "\\" . $action["class"]; |
|
| 25 | + $actionClass = class_exists($action["class"]) ? $action["class"] : "\\".$action["class"]; |
|
| 26 | 26 | $class = (method_exists($actionClass, "getInstance")) ? $actionClass::getInstance() : new $actionClass; |
| 27 | 27 | return $class; |
| 28 | 28 | } |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | $expr = preg_quote($expr, '/'); |
| 109 | 109 | $expr = str_replace('###', '(.*)', $expr); |
| 110 | 110 | $expr2 = preg_replace('/\(\.\*\)$/', '', $expr); |
| 111 | - $matched = preg_match('/^' . $expr . '\/?$/i', $path) || preg_match('/^' . $expr2 . '?$/i', $path); |
|
| 111 | + $matched = preg_match('/^'.$expr.'\/?$/i', $path) || preg_match('/^'.$expr2.'?$/i', $path); |
|
| 112 | 112 | return $matched; |
| 113 | 113 | } |
| 114 | 114 | |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public static function extractDomainInfo(\ReflectionClass $class, $domain) |
| 121 | 121 | { |
| 122 | - $path = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR; |
|
| 123 | - $path = realpath($path) . DIRECTORY_SEPARATOR; |
|
| 122 | + $path = dirname($class->getFileName()).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR; |
|
| 123 | + $path = realpath($path).DIRECTORY_SEPARATOR; |
|
| 124 | 124 | $tpl_path = "templates"; |
| 125 | 125 | $public_path = "public"; |
| 126 | 126 | $model_path = "models"; |
@@ -130,13 +130,13 @@ discard block |
||
| 130 | 130 | $model_path = ucfirst($model_path); |
| 131 | 131 | } |
| 132 | 132 | if ($class->hasConstant("TPL")) { |
| 133 | - $tpl_path .= DIRECTORY_SEPARATOR . $class->getConstant("TPL"); |
|
| 133 | + $tpl_path .= DIRECTORY_SEPARATOR.$class->getConstant("TPL"); |
|
| 134 | 134 | } |
| 135 | 135 | return [ |
| 136 | 136 | "base" => $path, |
| 137 | - "template" => $path . $tpl_path, |
|
| 138 | - "model" => $path . $model_path, |
|
| 139 | - "public" => $path . $public_path, |
|
| 137 | + "template" => $path.$tpl_path, |
|
| 138 | + "model" => $path.$model_path, |
|
| 139 | + "public" => $path.$public_path, |
|
| 140 | 140 | ]; |
| 141 | 141 | } |
| 142 | 142 | |
@@ -158,9 +158,9 @@ discard block |
||
| 158 | 158 | if (count($parameters) > 0) foreach ($parameters as $param) { |
| 159 | 159 | if ($param->isOptional() && !is_array($param->getDefaultValue())) { |
| 160 | 160 | $params[$param->getName()] = $param->getDefaultValue(); |
| 161 | - $default = str_replace('{' . $param->getName() . '}', $param->getDefaultValue(), $regex); |
|
| 161 | + $default = str_replace('{'.$param->getName().'}', $param->getDefaultValue(), $regex); |
|
| 162 | 162 | } |
| 163 | - } else $default = $regex; |
|
| 163 | + }else $default = $regex; |
|
| 164 | 164 | |
| 165 | 165 | return array($regex, $default, $params); |
| 166 | 166 | } |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | $default = str_replace('{__DOMAIN__}', $module, $default); |
| 241 | 241 | $httpMethod = RouterHelper::extractReflectionHttpMethod($docComments); |
| 242 | 242 | $label = RouterHelper::extractReflectionLabel(str_replace('{__API__}', $api, $docComments)); |
| 243 | - $route = $httpMethod . "#|#" . $regex; |
|
| 243 | + $route = $httpMethod."#|#".$regex; |
|
| 244 | 244 | $info = [ |
| 245 | 245 | "method" => $method->getName(), |
| 246 | 246 | "params" => $params, |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | if (!Config::getInstance()->checkTryToSaveConfig() |
| 24 | 24 | && (preg_match('/^\/(admin|setup\-admin)/i', $route) || NULL !== Config::getInstance()->get('restricted')) |
| 25 | 25 | ) { |
| 26 | - if (!file_exists(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json')) { |
|
| 26 | + if (!file_exists(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json')) { |
|
| 27 | 27 | //Si no hay fichero de usuarios redirigimos directamente al gestor |
| 28 | 28 | return UserController::showAdminManager(); |
| 29 | 29 | } |
@@ -26,13 +26,13 @@ |
||
| 26 | 26 | { |
| 27 | 27 | $namespace = explode('\\', $this->getModelTableMap()); |
| 28 | 28 | $module = strtolower($namespace[0]); |
| 29 | - $secret = Config::getInstance()->get($module . '.api.secret'); |
|
| 29 | + $secret = Config::getInstance()->get($module.'.api.secret'); |
|
| 30 | 30 | if (NULL === $secret) { |
| 31 | 31 | $secret = Config::getInstance()->get("api.secret"); |
| 32 | 32 | } |
| 33 | 33 | if (NULL === $secret) { |
| 34 | 34 | $auth = TRUE; |
| 35 | - } else { |
|
| 35 | + }else { |
|
| 36 | 36 | $token = Request::getInstance()->getHeader('X-API-SEC-TOKEN'); |
| 37 | 37 | if (array_key_exists('API_TOKEN', $this->query)) { |
| 38 | 38 | $token = $this->query['API_TOKEN']; |