@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | $header = null; |
| 138 | 138 | if ($this->hasHeader($name)) { |
| 139 | 139 | $header = $this->header[$name]; |
| 140 | - } else if (array_key_exists('h_' . strtolower($name), $this->query)) { |
|
| 141 | - $header = $this->query['h_' . strtolower($name)]; |
|
| 142 | - } else if (array_key_exists('HTTP_' . strtoupper(str_replace('-', '_', $name)), $this->server)) { |
|
| 143 | - $header = $this->getServer('HTTP_' . strtoupper(str_replace('-', '_', $name))); |
|
| 140 | + }else if (array_key_exists('h_'.strtolower($name), $this->query)) { |
|
| 141 | + $header = $this->query['h_'.strtolower($name)]; |
|
| 142 | + }else if (array_key_exists('HTTP_'.strtoupper(str_replace('-', '_', $name)), $this->server)) { |
|
| 143 | + $header = $this->getServer('HTTP_'.strtoupper(str_replace('-', '_', $name))); |
|
| 144 | 144 | } |
| 145 | 145 | return $header ?: $default; |
| 146 | 146 | } |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | $url = $this->getServer('HTTP_ORIGIN'); |
| 255 | 255 | } |
| 256 | 256 | ob_start(); |
| 257 | - header('Location: ' . $url); |
|
| 257 | + header('Location: '.$url); |
|
| 258 | 258 | ob_end_clean(); |
| 259 | 259 | Security::getInstance()->updateSession(); |
| 260 | 260 | exit(t('Redirect...')); |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | $url = $this->getServerName(); |
| 271 | 271 | $protocol = $hasProtocol ? $this->getProtocol() : '//'; |
| 272 | 272 | if (!empty($protocol)) { |
| 273 | - $url = $protocol . $url; |
|
| 273 | + $url = $protocol.$url; |
|
| 274 | 274 | } |
| 275 | 275 | return $this->checkServerPort($url); |
| 276 | 276 | } |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | } |
| 292 | 292 | } |
| 293 | 293 | if (!in_array($port, [80, 443], true)) { |
| 294 | - $url .= ':' . $port; |
|
| 294 | + $url .= ':'.$port; |
|
| 295 | 295 | } |
| 296 | 296 | return $url; |
| 297 | 297 | } |
@@ -46,13 +46,13 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | $filePath = $returnPath = ''; |
| 48 | 48 | if (!file_exists($filePath)) { |
| 49 | - $filePath = BASE_DIR . $string; |
|
| 49 | + $filePath = BASE_DIR.$string; |
|
| 50 | 50 | } |
| 51 | 51 | $filenamePath = AssetsHelper::findDomainPath($string, $filePath); |
| 52 | - if(!empty($filenamePath)){ |
|
| 52 | + if (!empty($filenamePath)) { |
|
| 53 | 53 | $filePath = self::processAsset($string, $name, $return, $filenamePath); |
| 54 | 54 | $basePath = Config::getParam('resources.cdn.url', Request::getInstance()->getRootUrl(false)); |
| 55 | - $returnPath = empty($name) ? $basePath . '/' . $filePath : $name; |
|
| 55 | + $returnPath = empty($name) ? $basePath.'/'.$filePath : $name; |
|
| 56 | 56 | } |
| 57 | 57 | return $return ? $returnPath : ''; |
| 58 | 58 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $router = Router::getInstance(); |
| 71 | 71 | try { |
| 72 | 72 | return $router->getRoute($path, $absolute, $params); |
| 73 | - } catch (\Exception $e) { |
|
| 73 | + }catch (\Exception $e) { |
|
| 74 | 74 | Logger::log($e->getMessage()); |
| 75 | 75 | return $router->getRoute('', $absolute, $params); |
| 76 | 76 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | $filenamePath = self::extractPathname($path, $domains); |
| 167 | 167 | // Check if resources has been copied to public folders |
| 168 | 168 | if (!$debug) { |
| 169 | - $cacheFilename = Config::getParam('cache.var', '__initial__') . '.file.cache'; |
|
| 169 | + $cacheFilename = Config::getParam('cache.var', '__initial__').'.file.cache'; |
|
| 170 | 170 | $cachedFiles = Cache::getInstance()->readFromCache($cacheFilename, |
| 171 | 171 | 1, fn() => [], Cache::JSON, true) ?: []; |
| 172 | 172 | // Force the resource copy |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | * |
| 188 | 188 | * @return string|array |
| 189 | 189 | */ |
| 190 | - private static function extractPathname(string $path, $domains): string|array |
|
| 190 | + private static function extractPathname(string $path, $domains): string | array |
|
| 191 | 191 | { |
| 192 | 192 | $filenamePath = $path; |
| 193 | 193 | if (!empty($domains) && !file_exists($path)) { |
@@ -226,13 +226,13 @@ discard block |
||
| 226 | 226 | * @param string $base |
| 227 | 227 | * @param string $filePath |
| 228 | 228 | */ |
| 229 | - private static function putResourceContent(string|null $name, string $filenamePath, string $base, string $filePath): void |
|
| 229 | + private static function putResourceContent(string | null $name, string $filenamePath, string $base, string $filePath): void |
|
| 230 | 230 | { |
| 231 | 231 | $data = file_get_contents($filenamePath); |
| 232 | 232 | if (!empty($name)) { |
| 233 | - file_put_contents(WEB_DIR . DIRECTORY_SEPARATOR . $name, $data); |
|
| 234 | - } else { |
|
| 235 | - file_put_contents($base . $filePath, $data); |
|
| 233 | + file_put_contents(WEB_DIR.DIRECTORY_SEPARATOR.$name, $data); |
|
| 234 | + }else { |
|
| 235 | + file_put_contents($base.$filePath, $data); |
|
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | |
@@ -245,15 +245,15 @@ discard block |
||
| 245 | 245 | * @return string |
| 246 | 246 | * @throws GeneratorException |
| 247 | 247 | */ |
| 248 | - private static function processAsset(string $string, string|null $name = null, bool $return = true, string $filenamePath = ''): string |
|
| 248 | + private static function processAsset(string $string, string | null $name = null, bool $return = true, string $filenamePath = ''): string |
|
| 249 | 249 | { |
| 250 | 250 | $filePath = $filenamePath; |
| 251 | 251 | if (file_exists($filenamePath)) { |
| 252 | 252 | list($base, $htmlBase, $filePath) = AssetsHelper::calculateAssetPath($string, $name, $return, $filenamePath); |
| 253 | 253 | //Creamos el directorio si no existe |
| 254 | - GeneratorHelper::createDir($base . $htmlBase); |
|
| 254 | + GeneratorHelper::createDir($base.$htmlBase); |
|
| 255 | 255 | //Si se ha modificado |
| 256 | - if (!file_exists($base . $filePath) || filemtime($base . $filePath) < filemtime($filenamePath)) { |
|
| 256 | + if (!file_exists($base.$filePath) || filemtime($base.$filePath) < filemtime($filenamePath)) { |
|
| 257 | 257 | if ($htmlBase === 'css') { |
| 258 | 258 | self::processCssLines($filenamePath); |
| 259 | 259 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | public function init() |
| 55 | 55 | { |
| 56 | 56 | parent::init(); |
| 57 | - Logger::log(static::class . ' init', LOG_DEBUG); |
|
| 57 | + Logger::log(static::class.' init', LOG_DEBUG); |
|
| 58 | 58 | $this->domain = $this->getDomain(); |
| 59 | 59 | $this->hydrateRequestData(); |
| 60 | 60 | $this->hydrateOrders(); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | $this->checkFieldType(); |
| 65 | 65 | $this->setLoaded(true); |
| 66 | - Logger::log(static::class . ' loaded', LOG_DEBUG); |
|
| 66 | + Logger::log(static::class.' loaded', LOG_DEBUG); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | private function checkActions($method) |
@@ -159,14 +159,14 @@ discard block |
||
| 159 | 159 | $status = 200; |
| 160 | 160 | $saved = TRUE; |
| 161 | 161 | $model = $this->model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true); |
| 162 | - } else { |
|
| 162 | + }else { |
|
| 163 | 163 | $message = t('No se ha podido guardar el modelo seleccionado'); |
| 164 | 164 | } |
| 165 | - } catch (\Exception $e) { |
|
| 166 | - if(Config::getParam('debug')) { |
|
| 167 | - $message = t('Ha ocurrido un error intentando guardar el elemento: ') . '<br>' . $e->getMessage(); |
|
| 168 | - } else { |
|
| 169 | - $message = t('Ha ocurrido un error intentando guardar el elemento: ') . '<br>' . $e->getCode(); |
|
| 165 | + }catch (\Exception $e) { |
|
| 166 | + if (Config::getParam('debug')) { |
|
| 167 | + $message = t('Ha ocurrido un error intentando guardar el elemento: ').'<br>'.$e->getMessage(); |
|
| 168 | + }else { |
|
| 169 | + $message = t('Ha ocurrido un error intentando guardar el elemento: ').'<br>'.$e->getCode(); |
|
| 170 | 170 | } |
| 171 | 171 | $context = []; |
| 172 | 172 | if (null !== $e->getPrevious()) { |
@@ -205,14 +205,14 @@ discard block |
||
| 205 | 205 | $updated = TRUE; |
| 206 | 206 | $status = 200; |
| 207 | 207 | $model = $this->model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true); |
| 208 | - } else { |
|
| 208 | + }else { |
|
| 209 | 209 | $message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs'); |
| 210 | 210 | } |
| 211 | - } catch (\Exception $e) { |
|
| 212 | - if(Config::getParam('debug')) { |
|
| 213 | - $message = t('Ha ocurrido un error intentando actualizar el elemento: ') . '<br>' . $e->getMessage(); |
|
| 214 | - } else { |
|
| 215 | - $message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs: ') . '<br>' . $e->getCode(); |
|
| 211 | + }catch (\Exception $e) { |
|
| 212 | + if (Config::getParam('debug')) { |
|
| 213 | + $message = t('Ha ocurrido un error intentando actualizar el elemento: ').'<br>'.$e->getMessage(); |
|
| 214 | + }else { |
|
| 215 | + $message = t('Ha ocurrido un error intentando actualizar el elemento, por favor revisa los logs: ').'<br>'.$e->getCode(); |
|
| 216 | 216 | } |
| 217 | 217 | $context = []; |
| 218 | 218 | if (null !== $e->getPrevious()) { |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | } |
| 221 | 221 | Logger::log($e->getMessage(), LOG_CRIT, $context); |
| 222 | 222 | } |
| 223 | - } else { |
|
| 223 | + }else { |
|
| 224 | 224 | $message = t('No se ha encontrado el modelo al que se hace referencia para actualizar'); |
| 225 | 225 | } |
| 226 | 226 | |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | $this->model->delete($this->con); |
| 255 | 255 | $deleted = TRUE; |
| 256 | 256 | } |
| 257 | - } catch (\Exception $e) { |
|
| 257 | + }catch (\Exception $e) { |
|
| 258 | 258 | $context = []; |
| 259 | 259 | if (null !== $e->getPrevious()) { |
| 260 | 260 | $context[] = $e->getPrevious()->getMessage(); |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | $this->saveBulk(); |
| 287 | 287 | $saved = true; |
| 288 | 288 | $status = 200; |
| 289 | - } catch (\Exception $e) { |
|
| 289 | + }catch (\Exception $e) { |
|
| 290 | 290 | Logger::log($e->getMessage(), LOG_CRIT, $this->getRequest()->getData()); |
| 291 | 291 | $message = t('Bulk insert rolled back'); |
| 292 | 292 | } |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | if (null !== $this->list) { |
| 319 | 319 | if (array_key_exists(self::API_FIELDS_RESULT_FIELD, $this->query) && Config::getParam('api.field.types')) { |
| 320 | 320 | $return = $this->extractDataWithFormat(); |
| 321 | - } else { |
|
| 321 | + }else { |
|
| 322 | 322 | $return = $this->list->toArray(null, false, $this->fieldType ?: TableMap::TYPE_PHPNAME, false); |
| 323 | 323 | } |
| 324 | 324 | $total = 0; |
@@ -331,8 +331,8 @@ discard block |
||
| 331 | 331 | $pages = 1; |
| 332 | 332 | } |
| 333 | 333 | } |
| 334 | - } catch (\Exception $e) { |
|
| 335 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
| 334 | + }catch (\Exception $e) { |
|
| 335 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | return array($return, $total, $pages); |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | $return = array(); |
| 351 | 351 | if (NULL === $model || !method_exists($model, 'toArray')) { |
| 352 | 352 | $code = 404; |
| 353 | - } else { |
|
| 353 | + }else { |
|
| 354 | 354 | $return = $model->toArray($this->fieldType ?: TableMap::TYPE_PHPNAME, true, [], true); |
| 355 | 355 | } |
| 356 | 356 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | if (count($pks) === 1) { |
| 101 | 101 | $pks = array_keys($pks); |
| 102 | 102 | return [ |
| 103 | - $tableMap::TABLE_NAME . '.' . $pks[0] => Api::API_MODEL_KEY_FIELD |
|
| 103 | + $tableMap::TABLE_NAME.'.'.$pks[0] => Api::API_MODEL_KEY_FIELD |
|
| 104 | 104 | ]; |
| 105 | 105 | } |
| 106 | 106 | if (count($pks) > 1) { |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | $principal = ''; |
| 109 | 109 | $sep = 'CONCAT('; |
| 110 | 110 | foreach ($pks as $pk) { |
| 111 | - $apiPks[$tableMap::TABLE_NAME . '.' . $pk->getName()] = $pk->getPhpName(); |
|
| 112 | - $principal .= $sep . $tableMap::TABLE_NAME . '.' . $pk->getName(); |
|
| 113 | - $sep = ', "' . Api::API_PK_SEPARATOR . '", '; |
|
| 111 | + $apiPks[$tableMap::TABLE_NAME.'.'.$pk->getName()] = $pk->getPhpName(); |
|
| 112 | + $principal .= $sep.$tableMap::TABLE_NAME.'.'.$pk->getName(); |
|
| 113 | + $sep = ', "'.Api::API_PK_SEPARATOR.'", '; |
|
| 114 | 114 | } |
| 115 | 115 | $principal .= ')'; |
| 116 | 116 | $apiPks[$principal] = Api::API_MODEL_KEY_FIELD; |
@@ -137,10 +137,10 @@ discard block |
||
| 137 | 137 | $pks = ''; |
| 138 | 138 | $sep = ''; |
| 139 | 139 | foreach ($tableMap->getPrimaryKeys() as $pk) { |
| 140 | - $pks .= $sep . $pk->getFullyQualifiedName(); |
|
| 140 | + $pks .= $sep.$pk->getFullyQualifiedName(); |
|
| 141 | 141 | $sep = ', "|", '; |
| 142 | 142 | } |
| 143 | - $this->extraColumns['CONCAT("' . $tableMap->getPhpName() . ' #", ' . $pks . ')'] = Api::API_LIST_NAME_FIELD; |
|
| 143 | + $this->extraColumns['CONCAT("'.$tableMap->getPhpName().' #", '.$pks.')'] = Api::API_LIST_NAME_FIELD; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | if (null !== $column) { |
| 164 | 164 | $this->extraColumns[$column->getFullyQualifiedName()] = Api::API_LIST_NAME_FIELD; |
| 165 | - } else { |
|
| 165 | + }else { |
|
| 166 | 166 | $this->addClassListName($tableMap); |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | * @param $action |
| 174 | 174 | * @throws ApiException |
| 175 | 175 | */ |
| 176 | - private function addExtraColumns(ModelCriteria &$query, $action) |
|
| 176 | + private function addExtraColumns(ModelCriteria & $query, $action) |
|
| 177 | 177 | { |
| 178 | 178 | if (Api::API_ACTION_LIST === $action) { |
| 179 | 179 | $this->addDefaultListField(); |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | if (!empty($this->extraColumns)) { |
| 183 | 183 | if (Config::getParam('api.extrafields.compat', true)) { |
| 184 | 184 | $fields = array_values($this->extraColumns); |
| 185 | - } else { |
|
| 185 | + }else { |
|
| 186 | 186 | $returnFields = Request::getInstance()->getQuery(Api::API_FIELDS_RESULT_FIELD); |
| 187 | 187 | $fields = explode(',', $returnFields ?: ''); |
| 188 | 188 | $fields[] = self::API_MODEL_KEY_FIELD; |
@@ -216,32 +216,32 @@ discard block |
||
| 216 | 216 | /** |
| 217 | 217 | * @param ModelCriteria $query |
| 218 | 218 | */ |
| 219 | - protected function checkI18n(ModelCriteria &$query) |
|
| 219 | + protected function checkI18n(ModelCriteria & $query) |
|
| 220 | 220 | { |
| 221 | 221 | $this->extractApiLang(); |
| 222 | 222 | $model = $this->getModelNamespace(); |
| 223 | - $modelI18n = $model . 'I18n'; |
|
| 223 | + $modelI18n = $model.'I18n'; |
|
| 224 | 224 | if (method_exists($query, 'useI18nQuery')) { |
| 225 | 225 | $query->useI18nQuery($this->lang); |
| 226 | 226 | $modelParts = explode('\\', $modelI18n); |
| 227 | - $i18nMapClass = str_replace(end($modelParts), 'Map\\' . end($modelParts), $modelI18n) . 'TableMap'; |
|
| 227 | + $i18nMapClass = str_replace(end($modelParts), 'Map\\'.end($modelParts), $modelI18n).'TableMap'; |
|
| 228 | 228 | /** @var TableMap $modelI18nTableMap */ |
| 229 | 229 | $modelI18nTableMap = $i18nMapClass::getTableMap(); |
| 230 | 230 | foreach ($modelI18nTableMap->getColumns() as $columnMap) { |
| 231 | 231 | if (!$columnMap->isPrimaryKey()) { |
| 232 | 232 | $query->withColumn($columnMap->getFullyQualifiedName(), ApiHelper::getColumnMapName($columnMap)); |
| 233 | 233 | } elseif (!$columnMap->isForeignKey()) { |
| 234 | - $query->withColumn('IFNULL(' . $columnMap->getFullyQualifiedName() . ', "' . $this->lang . '")', ApiHelper::getColumnMapName($columnMap)); |
|
| 234 | + $query->withColumn('IFNULL('.$columnMap->getFullyQualifiedName().', "'.$this->lang.'")', ApiHelper::getColumnMapName($columnMap)); |
|
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | protected function cleanData(array &$data) { |
| 241 | - foreach($data as $key => &$value) { |
|
| 242 | - if(is_array($value)) { |
|
| 241 | + foreach ($data as $key => &$value) { |
|
| 242 | + if (is_array($value)) { |
|
| 243 | 243 | $this->cleanData($value); |
| 244 | - } else if(is_string($value)) { |
|
| 244 | + }else if (is_string($value)) { |
|
| 245 | 245 | $value = I18nHelper::cleanHtmlAttacks($value); |
| 246 | 246 | } |
| 247 | 247 | } |
@@ -257,12 +257,12 @@ discard block |
||
| 257 | 257 | $model->fromArray($data, ApiHelper::getFieldTypes()); |
| 258 | 258 | $tableMap = $this->getTableMap(); |
| 259 | 259 | try { |
| 260 | - if ($tableMap->hasRelation($tableMap->getPhpName() . 'I18n')) { |
|
| 261 | - $relateI18n = $tableMap->getRelation($tableMap->getPhpName() . 'I18n'); |
|
| 260 | + if ($tableMap->hasRelation($tableMap->getPhpName().'I18n')) { |
|
| 261 | + $relateI18n = $tableMap->getRelation($tableMap->getPhpName().'I18n'); |
|
| 262 | 262 | $i18NTableMap = $relateI18n->getLocalTable(); |
| 263 | 263 | $model->setLocale(array_key_exists('Locale', $data) ? $data['Locale'] : (array_key_exists('locale', $data) ? $data['locale'] : Request::header(Api::HEADER_API_LANG, 'es_ES'))); |
| 264 | 264 | foreach ($i18NTableMap->getColumns() as $columnMap) { |
| 265 | - $method = 'set' . $columnMap->getPhpName(); |
|
| 265 | + $method = 'set'.$columnMap->getPhpName(); |
|
| 266 | 266 | $dtoColumnName = ApiHelper::getColumnMapName($columnMap); |
| 267 | 267 | if (array_key_exists($dtoColumnName, $data) |
| 268 | 268 | && method_exists($model, $method) |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | - } catch (Exception $e) { |
|
| 274 | + }catch (Exception $e) { |
|
| 275 | 275 | Logger::log($e->getMessage(), LOG_DEBUG); |
| 276 | 276 | } |
| 277 | 277 | } |
@@ -58,14 +58,14 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | $dto[$property->getName()] = $value; |
| 61 | - } else { |
|
| 61 | + }else { |
|
| 62 | 62 | $type = InjectorHelper::extractVarType($property->getDocComment()); |
| 63 | 63 | $dto[$property->getName()] = $this->checkCastedValue($property->getValue($this), $type ?: 'string'); |
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | - } catch (\Exception $e) { |
|
| 68 | - Logger::log(get_class($this) . ': ' . $e->getMessage(), LOG_ERR); |
|
| 67 | + }catch (\Exception $e) { |
|
| 68 | + Logger::log(get_class($this).': '.$e->getMessage(), LOG_ERR); |
|
| 69 | 69 | } |
| 70 | 70 | return $dto; |
| 71 | 71 | } |
@@ -102,12 +102,12 @@ discard block |
||
| 102 | 102 | $this->$key[] = $dto; |
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | - } else { |
|
| 105 | + }else { |
|
| 106 | 106 | $this->$key = clone $this->__cache[$type]; |
| 107 | 107 | $this->$key->fromArray($value); |
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | - } else { |
|
| 110 | + }else { |
|
| 111 | 111 | $this->castValue($key, $value, $type); |
| 112 | 112 | } |
| 113 | 113 | } |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | /** |
| 135 | 135 | * @return mixed |
| 136 | 136 | */ |
| 137 | - public function jsonSerialize(): array|string|null |
|
| 137 | + public function jsonSerialize(): array | string | null |
|
| 138 | 138 | { |
| 139 | 139 | return $this->toArray(); |
| 140 | 140 | } |
@@ -180,14 +180,14 @@ discard block |
||
| 180 | 180 | default: |
| 181 | 181 | case 'string': |
| 182 | 182 | // Cleaning HTML dangerous tags |
| 183 | - if(is_array($rawValue)) { |
|
| 184 | - foreach($rawValue as &$item) { |
|
| 183 | + if (is_array($rawValue)) { |
|
| 184 | + foreach ($rawValue as &$item) { |
|
| 185 | 185 | $item = $this->checkCastedValue($item, $type); |
| 186 | 186 | } |
| 187 | 187 | $value = $rawValue; |
| 188 | - } elseif(is_string($rawValue)) { |
|
| 188 | + } elseif (is_string($rawValue)) { |
|
| 189 | 189 | $value = I18nHelper::cleanHtmlAttacks($rawValue); |
| 190 | - } else { |
|
| 190 | + }else { |
|
| 191 | 191 | $value = $rawValue; |
| 192 | 192 | } |
| 193 | 193 | break; |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | $value = (bool)$rawValue; |
| 205 | 205 | break; |
| 206 | 206 | } |
| 207 | - } else { |
|
| 207 | + }else { |
|
| 208 | 208 | $value = $rawValue; |
| 209 | 209 | } |
| 210 | 210 | return $value; |
@@ -26,10 +26,10 @@ discard block |
||
| 26 | 26 | $objects = scandir($dir); |
| 27 | 27 | foreach ($objects as $object) { |
| 28 | 28 | if ($object != "." && $object != "..") { |
| 29 | - if (filetype($dir . "/" . $object) == "dir") { |
|
| 30 | - self::deleteDir($dir . "/" . $object); |
|
| 31 | - } else { |
|
| 32 | - unlink($dir . "/" . $object); |
|
| 29 | + if (filetype($dir."/".$object) == "dir") { |
|
| 30 | + self::deleteDir($dir."/".$object); |
|
| 31 | + }else { |
|
| 32 | + unlink($dir."/".$object); |
|
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | } |
@@ -44,10 +44,10 @@ discard block |
||
| 44 | 44 | { |
| 45 | 45 | $rootDirs = array("css", "js", "media", "font"); |
| 46 | 46 | foreach ($rootDirs as $dir) { |
| 47 | - if (file_exists(WEB_DIR . DIRECTORY_SEPARATOR . $dir)) { |
|
| 47 | + if (file_exists(WEB_DIR.DIRECTORY_SEPARATOR.$dir)) { |
|
| 48 | 48 | try { |
| 49 | - self::deleteDir(WEB_DIR . DIRECTORY_SEPARATOR . $dir); |
|
| 50 | - } catch (\Exception $e) { |
|
| 49 | + self::deleteDir(WEB_DIR.DIRECTORY_SEPARATOR.$dir); |
|
| 50 | + }catch (\Exception $e) { |
|
| 51 | 51 | syslog(LOG_INFO, $e->getMessage()); |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | if (!empty($dir)) { |
| 65 | 65 | try { |
| 66 | 66 | if (!is_dir($dir) && @mkdir($dir, 0775, true) === false) { |
| 67 | - throw new Exception(t('Can\'t create directory ') . $dir); |
|
| 67 | + throw new Exception(t('Can\'t create directory ').$dir); |
|
| 68 | 68 | } |
| 69 | - } catch (\Exception $e) { |
|
| 69 | + }catch (\Exception $e) { |
|
| 70 | 70 | syslog(LOG_WARNING, $e->getMessage()); |
| 71 | 71 | if (!file_exists(dirname($dir))) { |
| 72 | - throw new GeneratorException($e->getMessage() . $dir); |
|
| 72 | + throw new GeneratorException($e->getMessage().$dir); |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public static function getTemplatePath(): string |
| 83 | 83 | { |
| 84 | - $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR; |
|
| 84 | + $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR; |
|
| 85 | 85 | return realpath($path); |
| 86 | 86 | } |
| 87 | 87 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | } elseif (!$reflector->isAbstract()) { |
| 110 | 110 | throw new GeneratorException(t('La clase definida debe ser abstracta'), 501); |
| 111 | 111 | } |
| 112 | - } else { |
|
| 112 | + }else { |
|
| 113 | 113 | throw new GeneratorException(t('La clase definida para extender la API no existe'), 501); |
| 114 | 114 | } |
| 115 | 115 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | GeneratorHelper::createDir($path); |
| 132 | 132 | $paths = array("js", "css", "img", "media", "font"); |
| 133 | 133 | foreach ($paths as $htmlPath) { |
| 134 | - GeneratorHelper::createDir($path . DIRECTORY_SEPARATOR . $htmlPath); |
|
| 134 | + GeneratorHelper::createDir($path.DIRECTORY_SEPARATOR.$htmlPath); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | // Generates the root needed files |
@@ -141,35 +141,35 @@ discard block |
||
| 141 | 141 | 'crossdomain' => 'crossdomain.xml', |
| 142 | 142 | 'humans' => 'humans.txt', |
| 143 | 143 | 'robots' => 'robots.txt', |
| 144 | - 'docker' => '..' . DIRECTORY_SEPARATOR . 'docker-compose.yml', |
|
| 144 | + 'docker' => '..'.DIRECTORY_SEPARATOR.'docker-compose.yml', |
|
| 145 | 145 | ]; |
| 146 | 146 | $verificable = ['humans', 'robots', 'docker']; |
| 147 | 147 | if (!$quiet) { |
| 148 | 148 | $output->writeln('Start creating html files'); |
| 149 | 149 | } |
| 150 | 150 | foreach ($files as $template => $filename) { |
| 151 | - if (in_array($template, $verificable) && file_exists($path . DIRECTORY_SEPARATOR . $filename)) { |
|
| 151 | + if (in_array($template, $verificable) && file_exists($path.DIRECTORY_SEPARATOR.$filename)) { |
|
| 152 | 152 | if (!$quiet) { |
| 153 | - $output->writeln($filename . ' already exists'); |
|
| 153 | + $output->writeln($filename.' already exists'); |
|
| 154 | 154 | } |
| 155 | 155 | continue; |
| 156 | 156 | } |
| 157 | - $text = Template::getInstance()->dump("generator/html/" . $template . '.html.twig'); |
|
| 158 | - if (false === file_put_contents($path . DIRECTORY_SEPARATOR . $filename, $text)) { |
|
| 157 | + $text = Template::getInstance()->dump("generator/html/".$template.'.html.twig'); |
|
| 158 | + if (false === file_put_contents($path.DIRECTORY_SEPARATOR.$filename, $text)) { |
|
| 159 | 159 | if (!$quiet) { |
| 160 | - $output->writeln('Can\t create the file ' . $filename); |
|
| 160 | + $output->writeln('Can\t create the file '.$filename); |
|
| 161 | 161 | } |
| 162 | - } else { |
|
| 162 | + }else { |
|
| 163 | 163 | if (!$quiet) { |
| 164 | - $output->writeln($filename . ' created successfully'); |
|
| 164 | + $output->writeln($filename.' created successfully'); |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | //Export base locale translations |
| 170 | - if (!file_exists(BASE_DIR . DIRECTORY_SEPARATOR . 'locale')) { |
|
| 171 | - GeneratorHelper::createDir(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
| 172 | - self::copyr(SOURCE_DIR . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'locale', BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
| 170 | + if (!file_exists(BASE_DIR.DIRECTORY_SEPARATOR.'locale')) { |
|
| 171 | + GeneratorHelper::createDir(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
| 172 | + self::copyr(SOURCE_DIR.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'locale', BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
@@ -185,12 +185,12 @@ discard block |
||
| 185 | 185 | { |
| 186 | 186 | if (file_exists($filenamePath)) { |
| 187 | 187 | $destfolder = basename($filenamePath); |
| 188 | - if (!file_exists(WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) || $debug || $force) { |
|
| 188 | + if (!file_exists(WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) || $debug || $force) { |
|
| 189 | 189 | if (is_dir($filenamePath)) { |
| 190 | - self::copyr($filenamePath, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder); |
|
| 191 | - } else { |
|
| 192 | - if (@copy($filenamePath, WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder) === FALSE) { |
|
| 193 | - throw new ConfigException("Can't copy " . $filenamePath . " to " . WEB_DIR . $dest . DIRECTORY_SEPARATOR . $destfolder); |
|
| 190 | + self::copyr($filenamePath, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder); |
|
| 191 | + }else { |
|
| 192 | + if (@copy($filenamePath, WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder) === FALSE) { |
|
| 193 | + throw new ConfigException("Can't copy ".$filenamePath." to ".WEB_DIR.$dest.DIRECTORY_SEPARATOR.$destfolder); |
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | } |
@@ -209,10 +209,10 @@ discard block |
||
| 209 | 209 | self::createDir($dst); |
| 210 | 210 | while (false !== ($file = readdir($dir))) { |
| 211 | 211 | if (($file != '.') && ($file != '..')) { |
| 212 | - if (is_dir($src . '/' . $file)) { |
|
| 213 | - self::copyr($src . '/' . $file, $dst . '/' . $file); |
|
| 214 | - } elseif (@copy($src . '/' . $file, $dst . '/' . $file) === false) { |
|
| 215 | - throw new ConfigException("Can't copy " . $src . " to " . $dst); |
|
| 212 | + if (is_dir($src.'/'.$file)) { |
|
| 213 | + self::copyr($src.'/'.$file, $dst.'/'.$file); |
|
| 214 | + } elseif (@copy($src.'/'.$file, $dst.'/'.$file) === false) { |
|
| 215 | + throw new ConfigException("Can't copy ".$src." to ".$dst); |
|
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | } |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | // TODO check more en locales |
| 47 | 47 | if (strtolower($locale) === 'en') { |
| 48 | 48 | $locale = 'en_GB'; |
| 49 | - } else { |
|
| 50 | - $locale = $locale . '_' . strtoupper($locale); |
|
| 49 | + }else { |
|
| 50 | + $locale = $locale.'_'.strtoupper($locale); |
|
| 51 | 51 | } |
| 52 | 52 | $defaultLocales = explode(',', Config::getParam('i18n.locales', '')); |
| 53 | 53 | if (!in_array($locale, array_merge($defaultLocales, self::$langs))) { |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | $translations = array(); |
| 67 | 67 | if (file_exists($absoluteFileName)) { |
| 68 | 68 | @include($absoluteFileName); |
| 69 | - } else { |
|
| 69 | + }else { |
|
| 70 | 70 | Cache::getInstance()->storeData($absoluteFileName, "<?php \$translations = array();\n", Cache::TEXT, TRUE); |
| 71 | 71 | } |
| 72 | 72 | |
@@ -83,13 +83,13 @@ discard block |
||
| 83 | 83 | public static function setLocale(string $default = null, string $customKey = null, bool $force = false): void |
| 84 | 84 | { |
| 85 | 85 | $locale = $force ? $default : self::extractLocale($default); |
| 86 | - Inspector::stats('[i18NHelper] Set locale to project [' . $locale . ']', Inspector::SCOPE_DEBUG); |
|
| 86 | + Inspector::stats('[i18NHelper] Set locale to project ['.$locale.']', Inspector::SCOPE_DEBUG); |
|
| 87 | 87 | // Load translations |
| 88 | - putenv("LC_ALL=" . $locale); |
|
| 88 | + putenv("LC_ALL=".$locale); |
|
| 89 | 89 | setlocale(LC_ALL, $locale); |
| 90 | 90 | // Load the locale path |
| 91 | - $localePath = BASE_DIR . DIRECTORY_SEPARATOR . 'locale'; |
|
| 92 | - Logger::log('Set locale dir ' . $localePath); |
|
| 91 | + $localePath = BASE_DIR.DIRECTORY_SEPARATOR.'locale'; |
|
| 92 | + Logger::log('Set locale dir '.$localePath); |
|
| 93 | 93 | GeneratorHelper::createDir($localePath); |
| 94 | 94 | bindtextdomain('translations', $localePath); |
| 95 | 95 | textdomain('translations'); |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | } |
| 113 | 113 | } elseif (is_object($data)) { |
| 114 | 114 | $properties = get_class_vars($data); |
| 115 | - if(is_array($properties)) { |
|
| 115 | + if (is_array($properties)) { |
|
| 116 | 116 | foreach (array_keys($properties) as $property) { |
| 117 | 117 | $data->$property = self::utf8Encode($data->$property); |
| 118 | 118 | } |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | ['i', 'i', 'i', 'i', 'I', 'I', 'I', 'I'], |
| 160 | 160 | ['o', 'o', 'o', 'o', 'O', 'O', 'O', 'O'], |
| 161 | 161 | ['u', 'u', 'u', 'u', 'U', 'U', 'U', 'U'], |
| 162 | - ['n', 'N', 'c', 'C',], |
|
| 162 | + ['n', 'N', 'c', 'C', ], |
|
| 163 | 163 | ]; |
| 164 | 164 | |
| 165 | 165 | $text = htmlspecialchars($string); |
@@ -179,24 +179,24 @@ discard block |
||
| 179 | 179 | */ |
| 180 | 180 | public static function findTranslations(string $path, string $locale): array |
| 181 | 181 | { |
| 182 | - $localePath = realpath(BASE_DIR . DIRECTORY_SEPARATOR . 'locale'); |
|
| 183 | - $localePath .= DIRECTORY_SEPARATOR . $locale . DIRECTORY_SEPARATOR . 'LC_MESSAGES' . DIRECTORY_SEPARATOR; |
|
| 182 | + $localePath = realpath(BASE_DIR.DIRECTORY_SEPARATOR.'locale'); |
|
| 183 | + $localePath .= DIRECTORY_SEPARATOR.$locale.DIRECTORY_SEPARATOR.'LC_MESSAGES'.DIRECTORY_SEPARATOR; |
|
| 184 | 184 | |
| 185 | 185 | $translations = array(); |
| 186 | 186 | if (file_exists($path)) { |
| 187 | 187 | $directory = dir($path); |
| 188 | 188 | while (false !== ($fileName = $directory->read())) { |
| 189 | 189 | GeneratorHelper::createDir($localePath); |
| 190 | - if (!file_exists($localePath . 'translations.po')) { |
|
| 191 | - file_put_contents($localePath . 'translations.po', ''); |
|
| 190 | + if (!file_exists($localePath.'translations.po')) { |
|
| 191 | + file_put_contents($localePath.'translations.po', ''); |
|
| 192 | 192 | } |
| 193 | - $inspectPath = realpath($path . DIRECTORY_SEPARATOR . $fileName); |
|
| 194 | - $cmdPhp = "export PATH=\$PATH:/opt/local/bin; xgettext " . |
|
| 195 | - $inspectPath . DIRECTORY_SEPARATOR . |
|
| 193 | + $inspectPath = realpath($path.DIRECTORY_SEPARATOR.$fileName); |
|
| 194 | + $cmdPhp = "export PATH=\$PATH:/opt/local/bin; xgettext ". |
|
| 195 | + $inspectPath.DIRECTORY_SEPARATOR. |
|
| 196 | 196 | "*.php --from-code=UTF-8 -j -L PHP --debug --force-po -o {$localePath}translations.po"; |
| 197 | - if (is_dir($path . DIRECTORY_SEPARATOR . $fileName) && preg_match('/^\./', $fileName) == 0) { |
|
| 198 | - $res = t('Revisando directorio: ') . $inspectPath; |
|
| 199 | - $res .= t('Comando ejecutado: ') . $cmdPhp; |
|
| 197 | + if (is_dir($path.DIRECTORY_SEPARATOR.$fileName) && preg_match('/^\./', $fileName) == 0) { |
|
| 198 | + $res = t('Revisando directorio: ').$inspectPath; |
|
| 199 | + $res .= t('Comando ejecutado: ').$cmdPhp; |
|
| 200 | 200 | $res .= shell_exec($cmdPhp); |
| 201 | 201 | usleep(10); |
| 202 | 202 | $translations[] = $res; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | $this->setStatusCode(Template::STATUS_OK); |
| 128 | 128 | break; |
| 129 | 129 | default: |
| 130 | - $this->setStatusCode('HTTP/1.0 ' . ($status ?: 200)); |
|
| 130 | + $this->setStatusCode('HTTP/1.0 '.($status ?: 200)); |
|
| 131 | 131 | break; |
| 132 | 132 | } |
| 133 | 133 | return $this; |
@@ -140,11 +140,11 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | private function setResponseHeaders($contentType = 'text/html', array $cookies = array()): void |
| 142 | 142 | { |
| 143 | - ResponseHelper::setHeader('X-Powered-By: ' . Config::getParam('poweredBy', 'PSFS')); |
|
| 143 | + ResponseHelper::setHeader('X-Powered-By: '.Config::getParam('poweredBy', 'PSFS')); |
|
| 144 | 144 | ResponseHelper::setStatusHeader($this->getStatusCode()); |
| 145 | 145 | ResponseHelper::setAuthHeaders($this->isPublicZone()); |
| 146 | 146 | ResponseHelper::setCookieHeaders($cookies); |
| 147 | - ResponseHelper::setHeader('Content-type: ' . $contentType); |
|
| 147 | + ResponseHelper::setHeader('Content-type: '.$contentType); |
|
| 148 | 148 | |
| 149 | 149 | } |
| 150 | 150 | |
@@ -162,16 +162,16 @@ discard block |
||
| 162 | 162 | Logger::log('Start output response'); |
| 163 | 163 | ob_start(); |
| 164 | 164 | $this->setResponseHeaders($contentType, $cookies); |
| 165 | - ResponseHelper::setHeader('Content-length: ' . strlen($output)); |
|
| 166 | - ResponseHelper::setHeader('CRC: ' . crc32($output)); |
|
| 165 | + ResponseHelper::setHeader('Content-length: '.strlen($output)); |
|
| 166 | + ResponseHelper::setHeader('CRC: '.crc32($output)); |
|
| 167 | 167 | |
| 168 | 168 | $needCache = Cache::needCache(); |
| 169 | 169 | $cache = Cache::getInstance(); |
| 170 | 170 | list($path, $cacheDataName) = $cache->getRequestCacheHash(); |
| 171 | 171 | if (null !== $cacheDataName && false !== $needCache && $this->getStatusCode() === Template::STATUS_OK) { |
| 172 | 172 | Logger::log('Saving output response into cache'); |
| 173 | - $cache->storeData('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName, $output); |
|
| 174 | - $cache->storeData('json' . DIRECTORY_SEPARATOR . $path . $cacheDataName . '.headers', headers_list(), Cache::JSON); |
|
| 173 | + $cache->storeData('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName, $output); |
|
| 174 | + $cache->storeData('json'.DIRECTORY_SEPARATOR.$path.$cacheDataName.'.headers', headers_list(), Cache::JSON); |
|
| 175 | 175 | } elseif (Request::getInstance()->getMethod() !== 'GET') { |
| 176 | 176 | $cache->flushCache(); |
| 177 | 177 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | ob_end_clean(); |
| 182 | 182 | Logger::log('End output response'); |
| 183 | 183 | $this->closeRender(); |
| 184 | - } else { |
|
| 184 | + }else { |
|
| 185 | 185 | return $output; |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -194,12 +194,12 @@ discard block |
||
| 194 | 194 | Logger::log('Close template render'); |
| 195 | 195 | $uri = Request::requestUri(); |
| 196 | 196 | Security::getInstance()->setSessionKey('lastRequest', array( |
| 197 | - 'url' => Request::getInstance()->getRootUrl() . $uri, |
|
| 197 | + 'url' => Request::getInstance()->getRootUrl().$uri, |
|
| 198 | 198 | 'ts' => microtime(true), |
| 199 | 199 | )); |
| 200 | 200 | Security::getInstance()->updateSession(); |
| 201 | 201 | EventHelper::handleEvents(EventHelper::EVENT_END_REQUEST); |
| 202 | - Logger::log('End request: ' . Request::requestUri(), LOG_INFO); |
|
| 202 | + Logger::log('End request: '.Request::requestUri(), LOG_INFO); |
|
| 203 | 203 | exit; |
| 204 | 204 | } |
| 205 | 205 | |
@@ -237,17 +237,17 @@ discard block |
||
| 237 | 237 | ///////////////////////////////////////////////////////////// |
| 238 | 238 | // Date in the past sets the value to already have been expired. |
| 239 | 239 | ResponseHelper::setHeader('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); |
| 240 | - ResponseHelper::setHeader('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); |
|
| 240 | + ResponseHelper::setHeader('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); |
|
| 241 | 241 | ResponseHelper::setHeader('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1 |
| 242 | 242 | ResponseHelper::setHeader('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1 |
| 243 | 243 | ResponseHelper::setHeader('Pragma: no-cache'); |
| 244 | 244 | ResponseHelper::setHeader('Expires: 0'); |
| 245 | 245 | ResponseHelper::setHeader('Content-Transfer-Encoding: binary'); |
| 246 | - ResponseHelper::setHeader('Content-type: ' . $content); |
|
| 247 | - ResponseHelper::setHeader('Content-length: ' . strlen($data)); |
|
| 248 | - ResponseHelper::setHeader('Content-Disposition: attachment; filename="' . $filename . '"'); |
|
| 246 | + ResponseHelper::setHeader('Content-type: '.$content); |
|
| 247 | + ResponseHelper::setHeader('Content-length: '.strlen($data)); |
|
| 248 | + ResponseHelper::setHeader('Content-Disposition: attachment; filename="'.$filename.'"'); |
|
| 249 | 249 | ResponseHelper::setHeader('Access-Control-Expose-Headers: Filename'); |
| 250 | - ResponseHelper::setHeader('Filename: ' . $filename); |
|
| 250 | + ResponseHelper::setHeader('Filename: '.$filename); |
|
| 251 | 251 | echo $data; |
| 252 | 252 | ob_flush(); |
| 253 | 253 | ob_end_clean(); |
@@ -89,11 +89,11 @@ discard block |
||
| 89 | 89 | public static function save($user) |
| 90 | 90 | { |
| 91 | 91 | $saved = true; |
| 92 | - $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true) ?: []; |
|
| 93 | - $admins[$user['username']]['hash'] = sha1($user['username'] . $user['password']); |
|
| 92 | + $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true) ?: []; |
|
| 93 | + $admins[$user['username']]['hash'] = sha1($user['username'].$user['password']); |
|
| 94 | 94 | $admins[$user['username']]['profile'] = $user['profile']; |
| 95 | 95 | |
| 96 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', $admins, Cache::JSONGZ, true); |
|
| 96 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', $admins, Cache::JSONGZ, true); |
|
| 97 | 97 | return $saved; |
| 98 | 98 | } |
| 99 | 99 | |
@@ -113,9 +113,9 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | public function deleteUser($user) |
| 115 | 115 | { |
| 116 | - $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', Cache::JSONGZ, true) ?: []; |
|
| 116 | + $admins = Cache::getInstance()->getDataFromFile(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', Cache::JSONGZ, true) ?: []; |
|
| 117 | 117 | unset($admins[$user]); |
| 118 | - Cache::getInstance()->storeData(CONFIG_DIR . DIRECTORY_SEPARATOR . 'admins.json', $admins, Cache::JSONGZ, true); |
|
| 118 | + Cache::getInstance()->storeData(CONFIG_DIR.DIRECTORY_SEPARATOR.'admins.json', $admins, Cache::JSONGZ, true); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |