diff options
author | Simon Rettberg | 2014-10-09 16:01:11 +0200 |
---|---|---|
committer | Simon Rettberg | 2014-10-09 16:01:11 +0200 |
commit | e1dc0d3c99217504de2ac8467156274786efc0bd (patch) | |
tree | 130d7fed1fff8aaaffe5942cf2a3d6bb1dad03c8 /inc/validator.inc.php | |
parent | Minor fixes and improvements (diff) | |
download | slx-admin-e1dc0d3c99217504de2ac8467156274786efc0bd.tar.gz slx-admin-e1dc0d3c99217504de2ac8467156274786efc0bd.tar.xz slx-admin-e1dc0d3c99217504de2ac8467156274786efc0bd.zip |
Big load of changes
- Added callback functionality for taskmanager tasks. You can launch
a task and define a callback function to be run when the task finished.
This requires activating the cronjob
- Added cron functionality: Add cronjob that calls the cron api every 5
minutes to use it. (See cron.inc.php)
- Added eventlog
- Added missing translations
- Merged main-menu-login and main-menu-logout
Diffstat (limited to 'inc/validator.inc.php')
-rw-r--r-- | inc/validator.inc.php | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/inc/validator.inc.php b/inc/validator.inc.php index 88be14f2..944ac2ef 100644 --- a/inc/validator.inc.php +++ b/inc/validator.inc.php @@ -12,18 +12,20 @@ class Validator public static function validate($condition, $value) { - if (empty($condition)) return $value; + if (empty($condition)) + return $value; $data = explode(':', $condition, 2); switch ($data[0]) { - case 'regex': - if (preg_match($data[1], $value)) return $value; - return false; - case 'list': - return self::validateList($data[1], $value); - case 'function': - return self::$data[1]($value); - default: - Util::traceError('Unknown validation method: ' . $data[0]); + case 'regex': + if (preg_match($data[1], $value)) + return $value; + return false; + case 'list': + return self::validateList($data[1], $value); + case 'function': + return self::$data[1]($value); + default: + Util::traceError('Unknown validation method: ' . $data[0]); } } @@ -36,11 +38,29 @@ class Validator */ private static function linuxPassword($value) { - if (empty($value)) return ''; - if (preg_match('/^\$6\$.+\$./', $value)) return $value; + if (empty($value)) + return ''; + if (preg_match('/^\$6\$.+\$./', $value)) + return $value; return Crypto::hash6($value); } - + + /** + * "Fix" network share path for SMB shares where a backslash + * is used instead of a slash. + * @param string $value network path + * @return string cleaned up path + */ + private static function networkShare($value) + { + $value = trim($value); + if (substr($value, 0, 2) === '\\\\') + $value = str_replace('\\', '/', $value); + if (substr($value, 0, 2) === '//') + $value = str_replace(' ', '\\040', $value); + return $value; + } + /** * Validate value against list. * @param string $list The list as a string of items, separated by "|" @@ -50,9 +70,9 @@ class Validator private static function validateList($list, $value) { $list = explode('|', $list); - if (in_array($value, $list)) return $value; + if (in_array($value, $list)) + return $value; return false; } } - |