mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2026-11-20 23:43:26 +03:00
- split add() function to - set() (validate values) and - store() (write to database) - set(): - replace $checked with $this->values - store validation summary in $this->values_valid PFAHandler.php: - change _inp_* functions to return true/false if value is (in)valid instead if the sanitized value. They now also set $this->errormsg[] (not the final solution, but works for now) git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1210 a1433add-5e2c-0410-b055-b7f2511e0802
38 lines
962 B
PHP
38 lines
962 B
PHP
<?php
|
|
class PFAHandler {
|
|
|
|
/**
|
|
* @return return value of previously called method
|
|
*/
|
|
public function result() {
|
|
return $this->return;
|
|
}
|
|
|
|
|
|
/**
|
|
* functions for basic input validation
|
|
*/
|
|
function _inp_num($field, $val) {
|
|
$valid = is_numeric($val);
|
|
if ($val < -1) $valid = false;
|
|
if (!$valid) $this->errormsg[] = "$field must be numeric";
|
|
return $valid;
|
|
# return (int)($val);
|
|
}
|
|
|
|
function _inp_bool($field, $val) {
|
|
if ($val == "0" || $val == "1") return true;
|
|
$this->errormsg[] = "$field must be boolean";
|
|
return false;
|
|
# return $val ? db_get_boolean(true): db_get_boolean(false);
|
|
}
|
|
|
|
function _inp_password($field, $val){
|
|
# TODO: fetchmail specific. Not suited for mailbox/admin passwords.
|
|
return false;
|
|
# return base64_encode($val);
|
|
}
|
|
|
|
}
|
|
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|