|
|
@ -167,16 +167,6 @@ class AppModelValidator |
|
|
|
return $this->_config->page->keywords->required; |
|
|
|
return $this->_config->page->keywords->required; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getPageKeywordsLengthMin() : int |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return $this->_config->page->keywords->length->min; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getPageKeywordsLengthMax() : int |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return $this->_config->page->keywords->length->max; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getPageKeywordsQuantityMin() : int |
|
|
|
public function getPageKeywordsQuantityMin() : int |
|
|
|
{ |
|
|
|
{ |
|
|
|
return $this->_config->page->keywords->quantity->min; |
|
|
|
return $this->_config->page->keywords->quantity->min; |
|
|
@ -187,14 +177,9 @@ class AppModelValidator |
|
|
|
return $this->_config->page->keywords->quantity->max; |
|
|
|
return $this->_config->page->keywords->quantity->max; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getPageKeywordsRegex() : string |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return $this->_config->page->keywords->regex; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function pageKeywords(mixed $value, array &$error = []) : bool |
|
|
|
public function pageKeywords(mixed $value, array &$error = []) : bool |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!is_array($value)) |
|
|
|
if (!is_string($value)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
array_push( |
|
|
|
array_push( |
|
|
|
$error, |
|
|
|
$error, |
|
|
@ -214,67 +199,60 @@ class AppModelValidator |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($this->getPageKeywordsRequired()) |
|
|
|
|
|
|
|
{ |
|
|
|
$total = 0; |
|
|
|
$total = 0; |
|
|
|
|
|
|
|
|
|
|
|
foreach ($value as $keywords) |
|
|
|
foreach (explode(PHP_EOL, str_replace(['#', ',', ' '], PHP_EOL, $value)) as $keyword) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!is_string($kt)) |
|
|
|
$error = []; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$this->pageKeyword($keyword, $error)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
array_push( |
|
|
|
array_push( |
|
|
|
$error, |
|
|
|
$error, |
|
|
|
_('Invalid magnet keyword value data type') |
|
|
|
_('Invalid page keyword'), |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!preg_match(MAGNET_KT_REGEX, $kt)) |
|
|
|
$total++; |
|
|
|
{ |
|
|
|
|
|
|
|
array_push( |
|
|
|
|
|
|
|
$error, |
|
|
|
|
|
|
|
sprintf( |
|
|
|
|
|
|
|
_('Magnet keyword format does not match condition "%s"'), |
|
|
|
|
|
|
|
MAGNET_KT_REGEX |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mb_strlen($kt) < MAGNET_KT_MIN_LENGTH || |
|
|
|
if ($total < $this->getPageKeywordsQuantityMin() || |
|
|
|
mb_strlen($kt) > MAGNET_KT_MAX_LENGTH) |
|
|
|
$total > $this->getPageKeywordsQuantityMax()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
array_push( |
|
|
|
array_push( |
|
|
|
$error, |
|
|
|
$error, |
|
|
|
sprintf( |
|
|
|
sprintf( |
|
|
|
_('Magnet keyword out of %s-%s chars range'), |
|
|
|
_('Page keywords quantity out of %s-%s range'), |
|
|
|
MAGNET_KT_MIN_LENGTH, |
|
|
|
$this->getPageKeywordsQuantityMin(), |
|
|
|
MAGNET_KT_MAX_LENGTH |
|
|
|
$this->getPageKeywordsQuantityMax() |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$total++; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ($total < MAGNET_KT_MIN_QUANTITY || |
|
|
|
/// Page keyword |
|
|
|
$total > MAGNET_KT_MAX_QUANTITY) |
|
|
|
public function getPageKeywordLengthMin() : int |
|
|
|
{ |
|
|
|
{ |
|
|
|
array_push( |
|
|
|
return $this->_config->page->keyword->length->min; |
|
|
|
$error, |
|
|
|
} |
|
|
|
sprintf( |
|
|
|
|
|
|
|
_('Magnet keywords quantity out of %s-%s range'), |
|
|
|
|
|
|
|
MAGNET_KT_MIN_QUANTITY, |
|
|
|
|
|
|
|
MAGNET_KT_MAX_QUANTITY |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
public function getPageKeywordLengthMax() : int |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return $this->_config->page->keyword->length->max; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
public function getPageKeywordRegex() : string |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return $this->_config->page->keyword->regex; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function pageKeyword(mixed $value, array &$error = []) : bool |
|
|
|
public function pageKeyword(mixed $value, array &$error = []) : bool |
|
|
@ -289,29 +267,28 @@ class AppModelValidator |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!preg_match($this->getPageKeywordsRegex(), $value)) |
|
|
|
if (!preg_match($this->getPageKeywordRegex(), $value)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
array_push( |
|
|
|
array_push( |
|
|
|
$error, |
|
|
|
$error, |
|
|
|
sprintf( |
|
|
|
sprintf( |
|
|
|
_('Page keyword "%s" format does not match condition "%s"'), |
|
|
|
_('Page keyword format does not match condition "%s"'), |
|
|
|
$value, |
|
|
|
$this->getPageKeywordRegex() |
|
|
|
$this->getPageKeywordsRegex() |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mb_strlen($value) < $this->getPageDescriptionLengthMin() || |
|
|
|
if (mb_strlen($value) < $this->getPageKeywordLengthMin() || |
|
|
|
mb_strlen($value) > $this->getPageDescriptionLengthMax()) |
|
|
|
mb_strlen($value) > $this->getPageKeywordLengthMax()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
array_push( |
|
|
|
array_push( |
|
|
|
$error, |
|
|
|
$error, |
|
|
|
sprintf( |
|
|
|
sprintf( |
|
|
|
_('Page description out of %s-%s chars range'), |
|
|
|
_('Page keyword out of %s-%s chars range'), |
|
|
|
$this->getPageDescriptionLengthMin(), |
|
|
|
$this->getPageKeywordLengthMin(), |
|
|
|
$this->getPageDescriptionLengthMax() |
|
|
|
$this->getPageKeywordLengthMax() |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
@ -327,6 +304,11 @@ class AppModelValidator |
|
|
|
return $this->_config->page->torrent->required; |
|
|
|
return $this->_config->page->torrent->required; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function getPageTorrentMimeTypes() : array |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return $this->_config->page->torrent->mime; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Common |
|
|
|
// Common |
|
|
|
public function host(mixed $value, array &$error = []) : bool |
|
|
|
public function host(mixed $value, array &$error = []) : bool |
|
|
|
{ |
|
|
|
{ |
|
|
|