コード例 #1
0
 /**
  * Guess values for the following fields
  *  - EMAIL
  *  - NAME
  *  - FNAME
  *  - LNAME
  *
  * @return array
  */
 public function guessed()
 {
     $guessed = array();
     $fields = $this->fields->all();
     foreach ($fields as $field => $value) {
         // is this an email value? assume email field
         if (empty($guessed['EMAIL']) && is_string($value) && is_email($value)) {
             $guessed['EMAIL'] = $value;
             continue;
         }
         // remove special characters from field name
         $simple_key = str_replace(array('-', '_'), '', $field);
         if (empty($guessed['NAME']) && in_array($simple_key, array('NAME', 'YOURNAME', 'USERNAME', 'FULLNAME', 'CONTACTNAME'))) {
             // find name field
             $guessed['NAME'] = $value;
         } elseif (empty($guessed['FNAME']) && in_array($simple_key, array('FIRSTNAME', 'FNAME', 'GIVENNAME', 'FORENAME'))) {
             // find first name field
             $guessed['FNAME'] = $value;
         } elseif (empty($guessed['LNAME']) && in_array($simple_key, array('LASTNAME', 'LNAME', 'SURNAME', 'FAMILYNAME'))) {
             // find last name field
             $guessed['LNAME'] = $value;
         }
     }
     return $guessed;
 }
コード例 #2
0
 /**
  * Guess values for the following fields
  *  - EMAIL
  *  - NAME
  *  - FNAME
  *  - LNAME
  *
  * @return array
  */
 public function guessed()
 {
     $guessed = array();
     $fields = $this->fields->all();
     foreach ($fields as $field => $value) {
         // transform value into array to support 1-level arrays
         $sub_fields = is_array($value) ? $value : array($value);
         foreach ($sub_fields as $sub_field_value) {
             // is this an email value? if so, assume it's the EMAIL field
             if (empty($guessed['EMAIL']) && is_string($sub_field_value) && is_email($sub_field_value)) {
                 $guessed['EMAIL'] = $sub_field_value;
                 continue 2;
             }
         }
         // remove special characters from field name
         $simple_key = str_replace(array('-', '_', ' '), '', $field);
         if (empty($guessed['FNAME']) && $this->string_contains($simple_key, array('FIRSTNAME', 'FNAME', 'GIVENNAME', 'FORENAME'))) {
             // find first name field
             $guessed['FNAME'] = $value;
         } elseif (empty($guessed['LNAME']) && $this->string_contains($simple_key, array('LASTNAME', 'LNAME', 'SURNAME', 'FAMILYNAME'))) {
             // find last name field
             $guessed['LNAME'] = $value;
         } elseif (empty($guessed['NAME']) && $this->string_contains($simple_key, 'NAME')) {
             // find name field
             $guessed['NAME'] = $value;
         }
     }
     return $guessed;
 }
コード例 #3
0
ファイル: class-request.php プロジェクト: nihrain/accelerate
 /**
  * @return string
  */
 public function get_client_ip()
 {
     $headers = function_exists('apache_request_headers') ? apache_request_headers() : $this->server->all();
     if (array_key_exists('X-Forwarded-For', $headers) && filter_var($headers['X-Forwarded-For'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
         return $headers['X-Forwarded-For'];
     }
     if (array_key_exists('HTTP_X_FORWARDED_FOR', $headers) && filter_var($headers['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
         return $headers['HTTP_X_FORWARDED_FOR'];
     }
     return $this->server->get('REMOTE_ADDR', '');
 }