Subversion Repositories php_users

Rev

Rev 7 | Rev 16 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7 Rev 10
Line 90... Line 90...
90
            'form test' => 'login',    // field to test if form submitted
90
            'form test' => 'login',    // field to test if form submitted
91
            'fields' => array(
91
            'fields' => array(
92
               'login'  => array(
92
               'login'  => array(
93
                     'label'        => 'Username',       // login name column name
93
                     'label'        => 'Username',       // login name column name
94
                     'html type'    => 'text',
94
                     'html type'    => 'text',
95
                     'filter'       => '/[a-zA-Z0-9_]/',
95
                     'filter'       => '/^[a-zA-Z0-9_]+$/',
96
                     'instructions' => 'Username can only contain alpha numerics and an underscore',
96
                     'instructions' => 'Username can only contain alpha numerics and an underscore',
97
                     'hint'         => 'Change User Name'
97
                     'hint'         => 'Change User Name'
98
                     ),
98
                     ),
99
               'pass'   => array( 
99
               'pass'   => array( 
100
                     'label'        => 'Password',    // password column name
100
                     'label'        => 'Password',    // password column name
Line 474... Line 474...
474
            if ( isset( $record['restrict'] ) && ( $this->data['id'] == $this->workingOn['id'] ) )
474
            if ( isset( $record['restrict'] ) && ( $this->data['id'] == $this->workingOn['id'] ) )
475
               continue;
475
               continue;
476
            $htmlFieldName = $this->dbDefinition['input prefix'] . $field;
476
            $htmlFieldName = $this->dbDefinition['input prefix'] . $field;
477
            $temp = '';
477
            $temp = '';
478
            switch ( $record['html type'] ) {
478
            switch ( $record['html type'] ) {
479
               case 'textarea':
-
 
480
               case 'text' :
-
 
481
                  if ( $this->workingOn['id'] == -1 || ( isset( $_REQUEST[$htmlFieldName] ) && $_REQUEST[$htmlFieldName] !== $this->workingOn[$field] ) ) {
-
 
482
                     $data[$field] = $_REQUEST[$htmlFieldName];
-
 
483
                     if ( isset( $record['filter'] ) && preg_filter( $record['filter'], '', $temp ) !== $temp ) {
-
 
484
                        $this->errors[] = sprintf( "Invalid characters in %s, %s", $record['label'], $record['instructions'] );
-
 
485
                        $temp = '';
-
 
486
                     }
-
 
487
                  }
-
 
488
                  break;
-
 
489
               case 'password':
479
               case 'password':
490
                  if ( ! empty( $_REQUEST[$htmlFieldName] ) )
480
                  if ( ! empty( $_REQUEST[$htmlFieldName] ) ) {
491
                     $data[$field] = password_hash( $_REQUEST[$htmlFieldName], PASSWORD_DEFAULT );
481
                     $data[$field] = password_hash( $_REQUEST[$htmlFieldName], PASSWORD_DEFAULT );
-
 
482
                     if ( isset( $this->dbDefinition['tables']['users']['fields']['last password change'] ) ) {
-
 
483
                        $data['last password change'] = date("YmdHis");
-
 
484
                     }
-
 
485
                  }
492
                  break;
486
                  break;
493
               case 'boolean' :
487
               case 'boolean' :
494
                  if ( $this->workingOn['id'] == -1 || ( isset( $_REQUEST[$htmlFieldName] ) != $this->workingOn[$field] ) ) {
488
                  if ( $this->workingOn['id'] == -1 || ( isset( $_REQUEST[$htmlFieldName] ) != $this->workingOn[$field] ) ) {
495
                     $data[$field] = isset( $_REQUEST[$htmlFieldName] ) ? 1 : 0;
489
                     $data[$field] = isset( $_REQUEST[$htmlFieldName] ) ? 1 : 0;
496
                  }
490
                  }
497
                  break;
491
                  break;
-
 
492
               default : // text, textarea, other things like this
-
 
493
                  if ( $this->workingOn['id'] == -1 || ( isset( $_REQUEST[$htmlFieldName] ) && $_REQUEST[$htmlFieldName] !== $this->workingOn[$field] ) ) {
-
 
494
                     $data[$field] = $_REQUEST[$htmlFieldName];
-
 
495
                     if ( isset( $record['filter'] ) && preg_match( $record['filter'], $data[$field] ) !== 1 ) {
-
 
496
                        $this->errors[] = sprintf( "Invalid characters in %s, %s", $record['label'], $record['instructions'] );
-
 
497
                        unset( $data[$field] );
-
 
498
                     }
-
 
499
                  }
-
 
500
                  break;
498
            } // switch
501
            } // switch
499
         } // foreach
502
         } // foreach
500
         if ( count($this->errors) ) { // we have some errors
503
         if ( count($this->errors) ) { // we have some errors
501
            $this->errors[] = 'Record not updated';
504
            $this->errors[] = 'Record not updated';
502
            return 'Error';
505
            return 'Error';