| | |
| | | /**
|
| | | * Get the key => value array of a form filed from a datasource definitiom
|
| | | *
|
| | | * @param field = NEW oder EDIT
|
| | | * @param field = array with field definition
|
| | | * @param record = Dataset as array
|
| | | * @return key => value array for the value field of a form
|
| | | */
|
| | |
| | | if($record[$key] > 0) {
|
| | | list($tag,$monat,$jahr) = explode('.',$record[$key]);
|
| | | $new_record[$key] = mktime(0,0,0,$monat,$tag,$jahr);
|
| | | }
|
| | | } else {
|
| | | $new_record[$key] = 0;
|
| | | }
|
| | | break;
|
| | | case 'INTEGER':
|
| | | $new_record[$key] = intval($record[$key]);
|
| | |
| | | function validateField($field_name, $field_value, $validators) {
|
| | |
|
| | | global $app;
|
| | |
|
| | | |
| | | // loop trough the validators
|
| | | foreach($validators as $validator) {
|
| | |
|
| | |
| | | $num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM ".$escape.$this->formDef['db_table'].$escape. " WHERE $field_name = '".$app->db->quote($field_value)."'");
|
| | | if($num_rec["number"] > 0) {
|
| | | $errmsg = $validator['errmsg'];
|
| | | $this->errorMessage .= $this->wordbook[$errmsg]."<br>\r\n";
|
| | | if(isset($this->wordbook[$errmsg])) {
|
| | | $this->errorMessage .= $this->wordbook[$errmsg]."<br>\r\n";
|
| | | } else {
|
| | | $this->errorMessage .= $errmsg."<br>\r\n";
|
| | | }
|
| | | }
|
| | | } else {
|
| | | $num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM ".$escape.$this->formDef['db_table'].$escape. " WHERE $field_name = '".$app->db->quote($field_value)."' AND ".$this->formDef['db_table_idx']." != ".$this->primary_id);
|
| | | if($num_rec["number"] > 0) {
|
| | | $errmsg = $validator['errmsg'];
|
| | | $this->errorMessage .= $this->wordbook[$errmsg]."<br>\r\n";
|
| | | if(isset($this->wordbook[$errmsg])) {
|
| | | $this->errorMessage .= $this->wordbook[$errmsg]."<br>\r\n";
|
| | | } else {
|
| | | $this->errorMessage .= $errmsg."<br>\r\n";
|
| | | }
|
| | | }
|
| | | }
|
| | | break;
|
| | | case 'NOTEMPTY':
|
| | | if(empty($field_value)) {
|
| | | $errmsg = $validator['errmsg'];
|
| | | $this->errorMessage .= $this->wordbook[$errmsg]."<br>\r\n";
|
| | | if(isset($this->wordbook[$errmsg])) {
|
| | | $this->errorMessage .= $this->wordbook[$errmsg]."<br>\r\n";
|
| | | } else {
|
| | | $this->errorMessage .= $errmsg."<br>\r\n";
|
| | | }
|
| | | }
|
| | | break;
|
| | | case 'ISEMAIL':
|
| | | if(!preg_match("/^\w+[\w.-]*\w+@\w+[\w.-]*\w+\.[a-z]{2,4}$/i", $field_value)) {
|
| | | if(!preg_match("/^\w+[\w.-]*\w+@\w+[\w.-]*\w+\.[a-z]{2,10}$/i", $field_value)) {
|
| | | $errmsg = $validator['errmsg'];
|
| | | $this->errorMessage .= $this->wordbook[$errmsg]."<br>\r\n";
|
| | | if(isset($this->wordbook[$errmsg])) {
|
| | | $this->errorMessage .= $this->wordbook[$errmsg]."<br>\r\n";
|
| | | } else {
|
| | | $this->errorMessage .= $errmsg."<br>\r\n";
|
| | | }
|
| | | }
|
| | | break;
|
| | | case 'ISINT':
|
| | | $tmpval = intval($field_value);
|
| | | if($tmpval === 0 and !empty($field_value)) {
|
| | | $errmsg = $validator['errmsg'];
|
| | | $this->errorMessage .= $this->wordbook[$errmsg]."<br>\r\n";
|
| | | if(isset($this->wordbook[$errmsg])) {
|
| | | $this->errorMessage .= $this->wordbook[$errmsg]."<br>\r\n";
|
| | | } else {
|
| | | $this->errorMessage .= $errmsg."<br>\r\n";
|
| | | }
|
| | | }
|
| | | break;
|
| | | case 'ISPOSITIVE':
|
| | | if(!is_numeric($field_value) || $field_value <= 0){
|
| | | $errmsg = $validator['errmsg'];
|
| | | $this->errorMessage .= $this->wordbook[$errmsg]."<br>\r\n";
|
| | | if(isset($this->wordbook[$errmsg])) {
|
| | | $this->errorMessage .= $this->wordbook[$errmsg]."<br>\r\n";
|
| | | } else {
|
| | | $this->errorMessage .= $errmsg."<br>\r\n";
|
| | | }
|
| | | }
|
| | | break;
|
| | | case 'CUSTOM':
|
| | |
| | | $this->errorMessage .= "Custom validator class or function is empty<br>\r\n";
|
| | | }
|
| | | break;
|
| | | default:
|
| | | $this->errorMessage .= "Unknown Validator: ".$validator['type'];
|
| | | break;
|
| | | }
|
| | |
|
| | |
|
| | |
| | |
|
| | | // Daten in History tabelle speichern
|
| | | if($this->errorMessage == '' and $this->formDef['db_history'] == 'yes') $this->datalogSave($action,$primary_id,$record);
|
| | |
|
| | | // die($sql);
|
| | | return $sql;
|
| | | }
|
| | |
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | // Insert the server_id, if the record has a server_id
|
| | | $server_id = ($record_old["server_id"] > 0)?$record_old["server_id"]:0;
|
| | |
|
| | | if(count($diffrec) > 0) {
|
| | | $diffstr = $app->db->quote(serialize($diffrec));
|
| | | |
| | | // We need the full records in ISPConfig, not only the diffs
|
| | | $diffrec = array( 'old' => $record_old,
|
| | | 'new' => $record_new);
|
| | | |
| | | $diffstr = $app->db->quote(serialize($diffrec));
|
| | | $username = $app->db->quote($_SESSION["s"]["user"]["username"]);
|
| | | $dbidx = $this->formDef['db_table_idx'].":".$primary_id;
|
| | | $action = ($action == 'INSERT')?'i':'u';
|
| | | $sql = "INSERT INTO sys_datalog (dbtable,dbidx,action,tstamp,user,data) VALUES ('".$this->formDef['db_table']."','$dbidx','$action','".time()."','$username','$diffstr')";
|
| | | $app->db->query($sql);
|
| | | $sql = "INSERT INTO sys_datalog (dbtable,dbidx,server_id,action,tstamp,user,data) VALUES ('".$this->formDef['db_table']."','$dbidx','$server_id','$action','".time()."','$username','$diffstr')";
|
| | | $app->db->query($sql);
|
| | | }
|
| | |
|
| | | return true;
|