mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Move file upload validation class to functions
This commit is contained in:
parent
de586e0024
commit
84d5584150
@ -721,13 +721,15 @@ function validateCidr($cidr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validates a host or FQDN
|
// Validates a host or FQDN
|
||||||
function validate_host($host) {
|
function validate_host($host)
|
||||||
|
{
|
||||||
return preg_match('/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i', $host);
|
return preg_match('/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i', $host);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets night mode toggle value
|
// Gets night mode toggle value
|
||||||
// @return boolean
|
// @return boolean
|
||||||
function getNightmode(){
|
function getNightmode()
|
||||||
|
{
|
||||||
if ($_COOKIE['theme'] == 'lightsout.css') {
|
if ($_COOKIE['theme'] == 'lightsout.css') {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -736,7 +738,8 @@ function getNightmode(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// search array for matching string and return only first matching group
|
// search array for matching string and return only first matching group
|
||||||
function preg_only_match($pat,$haystack) {
|
function preg_only_match($pat,$haystack)
|
||||||
|
{
|
||||||
$match = "";
|
$match = "";
|
||||||
if(!empty($haystack) && !empty($pat)) {
|
if(!empty($haystack) && !empty($pat)) {
|
||||||
if(!is_array($haystack)) $haystack = array($haystack);
|
if(!is_array($haystack)) $haystack = array($haystack);
|
||||||
@ -754,10 +757,24 @@ function qr_encode($str)
|
|||||||
return preg_replace('/(?<!\\\)([\":;,])/', '\\\\\1', $str);
|
return preg_replace('/(?<!\\\)([\":;,])/', '\\\\\1', $str);
|
||||||
}
|
}
|
||||||
|
|
||||||
function evalHexSequence($string) {
|
function evalHexSequence($string)
|
||||||
|
{
|
||||||
$evaluator = function ($input) {
|
$evaluator = function ($input) {
|
||||||
return hex2bin($input[1]);
|
return hex2bin($input[1]);
|
||||||
};
|
};
|
||||||
return preg_replace_callback('/\\\x(..)/', $evaluator, $string);
|
return preg_replace_callback('/\\\x(..)/', $evaluator, $string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* File upload callback object
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class validation
|
||||||
|
{
|
||||||
|
public function check_name_length($object)
|
||||||
|
{
|
||||||
|
if (strlen($object->file['filename']) > 255) {
|
||||||
|
$object->set_error('File name is too long.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -167,15 +167,3 @@ function SaveOpenVPNConfig($status, $file, $authUser, $authPassword)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* File upload callback object
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class validation {
|
|
||||||
public function check_name_length($object)
|
|
||||||
{
|
|
||||||
if (strlen($object->file['filename']) > 255) {
|
|
||||||
$object->set_error('File name is too long.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user