'unique' // // "instance" and "args", if specified, are ignored // ) // // array( // 'method' => 'unique-case-insensitively' // // "instance" and "args", if specified, are ignored // ) // // array( // 'method' => 'unique-key' // // "instance" and "args", if specified, are ignored // ) // // array( // 'method' => 'unique-key-or-empty-string' // // "instance" and "args", if specified, are ignored // ) // // array( // 'method' => 'unique-key-or-some-other-string' // 'instance' => "other_string" // --OR-- // array( // 'other-str-1' , // 'other-str-2' , // ... // ) // // "args", if specified, is ignored // ) // // array( // 'method' => 'in-array-strict' // 'instance' => array(...) // // "args", if specified, is ignored // ) // // array( // 'method' => 'in-array-not-strict' // 'instance' => array(...) // // "args", if specified, is ignored // ) // // array( // 'method' => 'custom' // 'instance' => '' // 'args' => Any PHP value (including typically a PHP // object or associative array of // name=value pairs), that you want to pass // to the custom function. If NOT // specified, NULL will be passed. // ) // // array( // 'method' => 'email-address' // 'instance' => 'strict' | 'not-strict' (default) // // "args", if specified, is ignored // ) // // array( // 'method' => 'bool' // // "instance" and "args", if specified, are ignored // ) // // array( // 'method' => 'mysql-int-type-record-id' // 'args' => array( // 'question_optional' => TRUE/FALSE // ) // // "instance", if specified, is ignored // ) // // array( // 'method' => 'mysql-bigint-type-record-id' // 'args' => array( // 'question_optional' => TRUE/FALSE // ) // // "instance", if specified, is ignored // ) // // array( // 'method' => 'comma-separated-list-of-mysql-int-type-record-ids' // 'args' => array( // 'question_optional' => TRUE/FALSE , // 'asterisk_means_all' => TRUE/FALSE // ) // // "instance", if specified, is ignored // ) // // array( // 'method' => 'comma-separated-list-of-mysql-bigint-type-record-ids' // 'args' => array( // 'question_optional' => TRUE/FALSE , // 'asterisk_means_all' => TRUE/FALSE // ) // // "instance", if specified, is ignored // ) // // array( // 'method' => 'wordpress-role-name' // 'args' => array( // 'question_optional' => TRUE/FALSE // ) // // "instance", if specified, is ignored // ) // // array( // 'method' => 'comma-separated-list-of-wordpress-role-names' // 'args' => array( // 'question_optional' => TRUE/FALSE , // 'asterisk_means_all' => TRUE/FALSE // ) // // "instance", if specified, is ignored // ) // // array( // 'method' => 'signed-integer' // 'args' => array( // 'min' => <1+ digits> // 'max' => <1+ digits> // 'question_optional' => TRUE/FALSE // ) // // "instance", if specified, is ignored // ) // // A STRING, INT or FLOAT that's digits only - with // // optional leading minus sign. If either "min" and/or // // "max" are not specified or NULL/FALSE/empty string, // // then NO such "min"/"max" applies. // // array( // 'method' => 'unsigned-integer' // 'args' => array( // 'min' => <1+ digits> // 'max' => <1+ digits> // 'question_optional' => TRUE/FALSE // ) // // "instance", if specified, is ignored // ) // // A STRING, INT or FLOAT that's digits only (and has NO // // leading minus sign). If either "min" and/or "max" are // // not specified or NULL/FALSE/empty string, then NO such // // "min"/"max" applies. // // array( // 'method' => 'dashed-name' // ) // // Eg; "hello-world" // // array( // 'method' => 'notags' // ) // // No HTML or PHP (uses "strip_tags()") // // array( // 'method' => 'sequential-id' , // 'args' => array( // 'or_empty_string' => TRUE / FALSE // ) // ) // // ) // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $dataset_records , '$dataset_records' ) ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $question_adding , '$question_adding' ) ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $new_or_existing_field_value , '$new_or_existing_field_value' ) ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $record_being_editeds_index , '$record_being_editeds_index' ) ; // ========================================================================= // Init. // ========================================================================= $ns = __NAMESPACE__ ; $fn = __FUNCTION__ ; // ========================================================================= // Some useful shortcuts... // ========================================================================= if ( $question_adding ) { $adding_editing = 'Adding' ; } else { $adding_editing = 'Editing' ; } // ------------------------------------------------------------------------- $array_storage_field_slug = $array_storage_field_details['slug'] ; // ------------------------------------------------------------------------- $safe_array_storage_field_slug = htmlentities( $array_storage_field_slug ) ; // ------------------------------------------------------------------------- $safe_array_storage_field_title = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_stringUtils\to_title( $array_storage_field_slug ) ; // ------------------------------------------------------------------------- $safe_new_or_existing_field_value = htmlentities( $new_or_existing_field_value ) ; // ------------------------------------------------------------------------- $safe_dataset_title = htmlentities( $dataset_title ) ; // ========================================================================= // Identify the STORAGE MODE... // ========================================================================= if ( array_key_exists( 'storage_method' , $selected_datasets_dmdd ) && $selected_datasets_dmdd['storage_method'] === 'mysql' ) { $storage_mode = 'mysql' ; } else { $storage_mode = 'array-storage' ; } // ========================================================================= // Check this array storage field's "constraints"... // ========================================================================= // ------------------------------------------------------------------------- // Array ? // ------------------------------------------------------------------------- if ( ! is_array( $array_storage_field_details['constraints'] ) ) { return << $this_constraint ) { // --------------------------------------------------------------------- $constraint_number = $this_index + 1 ; // --------------------------------------------------------------------- // Array ? // --------------------------------------------------------------------- if ( ! is_array( $this_constraint ) ) { return << 64 ) { return << $this_record ) { // ------------------------------------------------------------- if ( array_key_exists( $array_storage_field_slug , $this_record ) && $this_record[ $array_storage_field_slug ] == $new_or_existing_field_value ) { // --------------------------------------------------------- if ( $question_adding || $record_being_editeds_index !== $this_record_index ) { // ----------------------------------------------------- return << $this_record ) { // ------------------------------------------------------------- if ( array_key_exists( $array_storage_field_slug , $this_record ) && strtolower( $this_record[ $array_storage_field_slug ] ) === $new_or_existing_field_value_lc ) { // --------------------------------------------------------- if ( $question_adding || $record_being_editeds_index !== $this_record_index ) { // ----------------------------------------------------- return << 'unique-key-or-some-other-string' // 'instance' => "other_string" // --OR-- // array( // 'other-str-1' , // 'other-str-2' , // ... // ) // // "args", if specified, is ignored // ) // // ----------------------------------------------------------------- $err_msg = << 'in-array-strict' // 'instance' => array(...) // // "args", if specified, is ignored // ) // // ----------------------------------------------------------------- if ( ! array_key_exists( 'instance' , $this_constraint ) ) { return << 32 ) { // -------------------------------------------------------------- return << 11 || ! ctype_digit( $parts[1] ) || strlen( $parts[1] ) > 6 ) { return $unix_timestamp_with_microseconds_error_message ; } // ------------------------------------------------------------- } else { // ------------------------------------------------------------- // "1234" expected... // ------------------------------------------------------------- if ( trim( $new_or_existing_field_value_str ) === '' || strlen( $new_or_existing_field_value_str ) > 11 || ! ctype_digit( $new_or_existing_field_value_str ) ) { return $unix_timestamp_with_microseconds_error_message ; } // ------------------------------------------------------------- } // ----------------------------------------------------------------- continue ; // ----------------------------------------------------------------- } elseif ( $this_constraint['method'] === 'custom' ) { // ================================================================= // FIELD CONSTRAINT = "CUSTOM" (FUNCTION) // ================================================================= // ----------------------------------------------------------------- // Here we should have (eg):- // // $this_constraint = array( // 'method' => 'custom' // 'instance' => '' // 'args' => Any PHP value (including typically a PHP // object or associative array of // name=value pairs), that you want to pass // to the custom function. If NOT // specified, NULL will be passed. // ) // // ----------------------------------------------------------------- if ( ! array_key_exists( 'instance' , $this_constraint ) ) { return << 512 ) { return <<( // $caller_apps_includes_dir , // $dataset_title , // $dataset_records , // $array_storage_field_details , // $question_adding , // $new_or_existing_field_value , // $record_being_editeds_index , // $custom_args // ) // - - - - - - - - - - - - - // RETURNS // o On SUCCESS! // - - - - - - // TRUE // // o On FAILURE! // - - - - - - // $error_message STRING // // NOTE! // ===== // If the error message string begins with "--ZEBRA--", then it's // assumed to be a "friendly" error message - that should be // displayed at the top of the (re-displayed) Zebra Form. // ------------------------------------------------------------------------- if ( ! array_key_exists( 'args' , $this_constraint ) ) { $custom_args = NULL ; } else { $custom_args = $this_constraint['args'] ; } // ----------------------------------------------------------------- $result = $this_constraint['instance']( $caller_apps_includes_dir , $dataset_title , $dataset_records , $array_storage_field_details , $question_adding , $new_or_existing_field_value , $record_being_editeds_index , $custom_args ) ; // ----------------------------------------------------------------- if ( is_string( $result ) ) { return $result ; } // ----------------------------------------------------------------- continue ; // ----------------------------------------------------------------- } elseif ( $this_constraint['method'] === 'email' ) { // ================================================================= // FIELD CONSTRAINT = "EMAIL" // ================================================================= // ----------------------------------------------------------------- // Here we should have (eg):- // // $this_constraint = array( // 'method' => 'email' // 'instance' => 'strict' (must pass all available email tests) // --OR-- // 'loose' (is accepted so long as it passes at // least one email test). // // "args", if specified, is ignored // ) // // ----------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $this_constraint ) ; $question_strict = FALSE ; // Must pass at least one test... // ----------------------------------------------------------------- if ( array_key_exists( 'instance' , $this_constraint ) && $this_constraint['instance'] === 'strict' ) { $question_strict = TRUE ; // Must pass ALL (available) email tests... } // ----------------------------------------------------------------- $question_loose = ! $question_strict ; $number_tests_available = 0 ; $number_tests_passed = 0 ; $bad_email = <<Please try again... EOT; // ----------------------------------------------------------------- // FILTER_VALIDATE_EMAIL // ----------------------------------------------------------------- // ------------------------------------------------------------------------- // mixed filter_var ( mixed $variable [, int $filter = FILTER_DEFAULT [, mixed $options ]] ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Filters a variable with a specified filter // // variable // Value to filter. // // filter // The ID of the filter to apply. The Types of filters manual page // lists the available filters. // // options // Associative array of options or bitwise disjunction of flags. If // filter accepts options, flags can be provided in "flags" field // of array. For the "callback" filter, callable type should be // passed. The callback must accept one argument, the value to be // filtered, and return the value after filtering/sanitizing it. // // // for filters that accept options, use this format // $options = array( // 'options' => array( // 'default' => 3, // value to return if the filter fails // // other options here // 'min_range' => 0 // ), // 'flags' => FILTER_FLAG_ALLOW_OCTAL, // ); // $var = filter_var('0755', FILTER_VALIDATE_INT, $options); // // // for filter that only accept flags, you can pass them directly // $var = filter_var('oops', FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); // // // for filter that only accept flags, you can also pass as an array // $var = filter_var('oops', FILTER_VALIDATE_BOOLEAN, // array('flags' => FILTER_NULL_ON_FAILURE)); // // // callback validate filter // function foo($value) // { // // Expected format: Surname, GivenNames // if (strpos($value, ", ") === false) return false; // list($surname, $givennames) = explode(", ", $value, 2); // $empty = (empty($surname) || empty($givennames)); // $notstrings = (!is_string($surname) || !is_string($givennames)); // if ($empty || $notstrings) { // return false; // } else { // return $value; // } // } // $var = filter_var('Doe, Jane Sue', FILTER_CALLBACK, array('options' => 'foo')); // // Returns the filtered data, or FALSE if the filter fails. // // (PHP 5 >= 5.2.0) // ------------------------------------------------------------------------- if ( function_exists( '\\filter_var' ) ) { $number_tests_available++ ; if ( \filter_var( $new_or_existing_field_value , FILTER_VALIDATE_EMAIL ) !== FALSE ) { if ( $question_loose ) { continue ; // Valid email } $number_tests_passed++ ; } } // ----------------------------------------------------------------- // /** // Validate an email address. // Provide email address (raw input) // Returns true if the email address has the email // address format and the domain exists. // */ // // /* // From: Linux Journal, Issue 158 // "Validate an E-Mail Address with PHP, the Right Way" // Douglas Lovell // Jun 01, 2007 // // http://www.linuxjournal.com/article/9585?page=0,0 // */ // ----------------------------------------------------------------- require_once( $caller_apps_includes_dir . '/validEmail-douglasLovell.php' ) ; // ----------------------------------------------------------------- if ( function_exists( '\\validEmail' ) ) { $number_tests_available++ ; if ( \validEmail( $new_or_existing_field_value ) ) { if ( $question_loose ) { continue ; // Valid email } $number_tests_passed++ ; } } // ----------------------------------------------------------------- if ( $number_tests_available === 0 ) { return <<= $number_tests_available ) { continue ; // Valid email } elseif ( $number_tests_passed === 0 ) { return $bad_email ; } // ----------------------------------------------------------------- // At least one - but NOT all available - tests passed... // ----------------------------------------------------------------- if ( $question_strict ) { return $bad_email ; } // ----------------------------------------------------------------- continue ; // Valid email // ----------------------------------------------------------------- } elseif ( $this_constraint['method'] === 'bool' ) { // ================================================================= // FIELD CONSTRAINT = "BOOL" // ================================================================= // ----------------------------------------------------------------- // Here we should have (eg):- // // $this_constraint = array( // 'method' => 'bool' // // "instance" and "args", if specified, are ignored // ) // // ----------------------------------------------------------------- if ( $new_or_existing_field_value !== '0' && $new_or_existing_field_value !== '1' ) { // $safe_new_or_existing_field_value = htmlentities( $new_or_existing_field_value ) ; return << 'mysql-int-type-record-id' // 'args' => array( // 'question_optional' => TRUE/FALSE // ) // // "instance", if specified, is ignored // ) // // ----------------------------------------------------------------- // ------------------------------------------------------------------------- // check_and_default_the_args( // $safe_dataset_title , // $safe_array_storage_field_slug , // $safe_array_storage_field_title , // $adding_editing , // $constraint_number , // $expected_members_and_their_defaults , // &$this_constraint // ) // - - - - - - - - - - - - - - - - - - - - - - - // $expected_members_and_their_defaults is like (eg):- // // $expected_members_and_their_defaults = array( // 'question_optional' => array( // 'allowed_types' => array( 'boolean' ) , // 'default_value' => FALSE // ) // 'asterisk_means_all' => array( // 'allowed_types' => array( 'boolean' ) , // 'default_value' => FALSE // ) // ) // // RETURNS // o On SUCCESS // TRUE // // o On FAILURE // $error_message STRING // ------------------------------------------------------------------------- $expected_members_and_their_defaults = array( 'question_optional' => array( 'allowed_types' => array( 'boolean' ) , 'default_value' => FALSE ) ) ; // ----------------------------------------------------------------- $result = check_and_default_the_args( $safe_dataset_title , $safe_array_storage_field_slug , $safe_array_storage_field_title , $adding_editing , $constraint_number , $expected_members_and_their_defaults , $this_constraint ) ; // ----------------------------------------------------------------- if ( is_string( $result ) ) { return $result ; } // ----------------------------------------------------------------- if ( trim( $new_or_existing_field_value ) === '' ) { // ------------------------------------------------------------- if ( $this_constraint['args']['question_optional'] !== TRUE ) { return << 'comma-separated-list-of-mysql-int-type-record-ids' // 'args' => array( // 'question_optional' => TRUE/FALSE , // 'asterisk_means_all' => TRUE/FALSE // ) // // "instance", if specified, is ignored // ) // // ----------------------------------------------------------------- // ------------------------------------------------------------------------- // check_and_default_the_args( // $safe_dataset_title , // $safe_array_storage_field_slug , // $safe_array_storage_field_title , // $adding_editing , // $constraint_number , // $expected_members_and_their_defaults , // &$this_constraint // ) // - - - - - - - - - - - - - - - - - - - - - - - // $expected_members_and_their_defaults is like (eg):- // // $expected_members_and_their_defaults = array( // 'question_optional' => array( // 'allowed_types' => array( 'boolean' ) , // 'default_value' => FALSE // ) // 'asterisk_means_all' => array( // 'allowed_types' => array( 'boolean' ) , // 'default_value' => FALSE // ) // ) // // RETURNS // o On SUCCESS // TRUE // // o On FAILURE // $error_message STRING // ------------------------------------------------------------------------- $expected_members_and_their_defaults = array( 'question_optional' => array( 'allowed_types' => array( 'boolean' ) , 'default_value' => FALSE ) , 'asterisk_means_all' => array( 'allowed_types' => array( 'boolean' ) , 'default_value' => FALSE ) ) ; // ----------------------------------------------------------------- $result = check_and_default_the_args( $safe_dataset_title , $safe_array_storage_field_slug , $safe_array_storage_field_title , $adding_editing , $constraint_number , $expected_members_and_their_defaults , $this_constraint ) ; // ----------------------------------------------------------------- if ( is_string( $result ) ) { return $result ; } // ----------------------------------------------------------------- $err_msg = << 'mysql-bigint-type-record-id' // 'args' => array( // 'question_optional' => TRUE/FALSE , // 'asterisk_means_all' => TRUE/FALSE // ) // // "instance", if specified, is ignored // ) // // ----------------------------------------------------------------- // ------------------------------------------------------------------------- // check_and_default_the_args( // $safe_dataset_title , // $safe_array_storage_field_slug , // $safe_array_storage_field_title , // $adding_editing , // $constraint_number , // $expected_members_and_their_defaults , // &$this_constraint // ) // - - - - - - - - - - - - - - - - - - - - - - - // $expected_members_and_their_defaults is like (eg):- // // $expected_members_and_their_defaults = array( // 'question_optional' => array( // 'allowed_types' => array( 'boolean' ) , // 'default_value' => FALSE // ) // 'asterisk_means_all' => array( // 'allowed_types' => array( 'boolean' ) , // 'default_value' => FALSE // ) // ) // // RETURNS // o On SUCCESS // TRUE // // o On FAILURE // $error_message STRING // ------------------------------------------------------------------------- $expected_members_and_their_defaults = array( 'question_optional' => array( 'allowed_types' => array( 'boolean' ) , 'default_value' => FALSE ) ) ; // ----------------------------------------------------------------- $result = check_and_default_the_args( $safe_dataset_title , $safe_array_storage_field_slug , $safe_array_storage_field_title , $adding_editing , $constraint_number , $expected_members_and_their_defaults , $this_constraint ) ; // ----------------------------------------------------------------- if ( is_string( $result ) ) { return $result ; } // ----------------------------------------------------------------- if ( trim( $new_or_existing_field_value ) === '' ) { // ------------------------------------------------------------- if ( $this_constraint['args']['question_optional'] !== TRUE ) { return << 'comma-separated-list-of-mysql-bigint-type-record-ids' // 'args' => array( // 'question_optional' => TRUE/FALSE , // 'asterisk_means_all' => TRUE/FALSE // ) // // "instance", if specified, is ignored // ) // // ----------------------------------------------------------------- // ------------------------------------------------------------------------- // check_and_default_the_args( // $safe_dataset_title , // $safe_array_storage_field_slug , // $safe_array_storage_field_title , // $adding_editing , // $constraint_number , // $expected_members_and_their_defaults , // &$this_constraint // ) // - - - - - - - - - - - - - - - - - - - - - - - // $expected_members_and_their_defaults is like (eg):- // // $expected_members_and_their_defaults = array( // 'question_optional' => array( // 'allowed_types' => array( 'boolean' ) , // 'default_value' => FALSE // ) // 'asterisk_means_all' => array( // 'allowed_types' => array( 'boolean' ) , // 'default_value' => FALSE // ) // ) // // RETURNS // o On SUCCESS // TRUE // // o On FAILURE // $error_message STRING // ------------------------------------------------------------------------- $expected_members_and_their_defaults = array( 'question_optional' => array( 'allowed_types' => array( 'boolean' ) , 'default_value' => FALSE ) , 'asterisk_means_all' => array( 'allowed_types' => array( 'boolean' ) , 'default_value' => FALSE ) ) ; // ----------------------------------------------------------------- $result = check_and_default_the_args( $safe_dataset_title , $safe_array_storage_field_slug , $safe_array_storage_field_title , $adding_editing , $constraint_number , $expected_members_and_their_defaults , $this_constraint ) ; // ----------------------------------------------------------------- if ( is_string( $result ) ) { return $result ; } // ----------------------------------------------------------------- $err_msg = << 'wordpress-role-name' // 'args' => array( // 'question_optional' => TRUE/FALSE // ) // // "instance", if specified, is ignored // ) // // ----------------------------------------------------------------- // ------------------------------------------------------------------------- // check_and_default_the_args( // $safe_dataset_title , // $safe_array_storage_field_slug , // $safe_array_storage_field_title , // $adding_editing , // $constraint_number , // $expected_members_and_their_defaults , // &$this_constraint // ) // - - - - - - - - - - - - - - - - - - - - - - - // $expected_members_and_their_defaults is like (eg):- // // $expected_members_and_their_defaults = array( // 'question_optional' => array( // 'allowed_types' => array( 'boolean' ) , // 'default_value' => FALSE // ) // 'asterisk_means_all' => array( // 'allowed_types' => array( 'boolean' ) , // 'default_value' => FALSE // ) // ) // // RETURNS // o On SUCCESS // TRUE // // o On FAILURE // $error_message STRING // ------------------------------------------------------------------------- $expected_members_and_their_defaults = array( 'question_optional' => array( 'allowed_types' => array( 'boolean' ) , 'default_value' => FALSE ) ) ; // ----------------------------------------------------------------- $result = check_and_default_the_args( $safe_dataset_title , $safe_array_storage_field_slug , $safe_array_storage_field_title , $adding_editing , $constraint_number , $expected_members_and_their_defaults , $this_constraint ) ; // ----------------------------------------------------------------- if ( is_string( $result ) ) { return $result ; } // ----------------------------------------------------------------- if ( trim( $new_or_existing_field_value ) === '' ) { // ------------------------------------------------------------- if ( $this_constraint['args']['question_optional'] !== TRUE ) { return <<roles ) ) { return << 'comma-separated-list-of-wordpress-role-names' // 'args' => array( // 'question_optional' => TRUE/FALSE , // 'asterisk_means_all' => TRUE/FALSE // ) // // "instance", if specified, is ignored // ) // // ----------------------------------------------------------------- // ------------------------------------------------------------------------- // check_and_default_the_args( // $safe_dataset_title , // $safe_array_storage_field_slug , // $safe_array_storage_field_title , // $adding_editing , // $constraint_number , // $expected_members_and_their_defaults , // &$this_constraint // ) // - - - - - - - - - - - - - - - - - - - - - - - // $expected_members_and_their_defaults is like (eg):- // // $expected_members_and_their_defaults = array( // 'question_optional' => array( // 'allowed_types' => array( 'boolean' ) , // 'default_value' => FALSE // ) // 'asterisk_means_all' => array( // 'allowed_types' => array( 'boolean' ) , // 'default_value' => FALSE // ) // ) // // RETURNS // o On SUCCESS // TRUE // // o On FAILURE // $error_message STRING // ------------------------------------------------------------------------- $expected_members_and_their_defaults = array( 'question_optional' => array( 'allowed_types' => array( 'boolean' ) , 'default_value' => FALSE ) , 'asterisk_means_all' => array( 'allowed_types' => array( 'boolean' ) , 'default_value' => FALSE ) ) ; // ----------------------------------------------------------------- $result = check_and_default_the_args( $safe_dataset_title , $safe_array_storage_field_slug , $safe_array_storage_field_title , $adding_editing , $constraint_number , $expected_members_and_their_defaults , $this_constraint ) ; // ----------------------------------------------------------------- if ( is_string( $result ) ) { return $result ; } // ----------------------------------------------------------------- $err_msg = <<roles // ) ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $allowed_role_names ) ; // ------------------------------------------------------------- foreach ( $parts as $this_candidate_wordpress_role_name ) { // --------------------------------------------------------- if ( ! array_key_exists( $this_candidate_wordpress_role_name , $wp_roles->roles ) ) { return $err_msg ; } // --------------------------------------------------------- } // ------------------------------------------------------------- } // ----------------------------------------------------------------- continue ; // ----------------------------------------------------------------- } elseif ( $this_constraint['method'] === 'grouped-random-password' ) { // ================================================================= // FIELD CONSTRAINT = "GROUPED-RANDOM-PASSWORD" // ================================================================= // ----------------------------------------------------------------- // Here we should have (eg):- // // $this_constraint = array( // 'method' => 'grouped-random-password' // 'args' => array( // 'number_groups' => 4 , // 'chars_per_group' => 4 , // 'group_separator' => '-' , // 'lowercase_only' => TRUE // ) // // "instance", if specified, is ignored // ) // // Where 'args' is like the $options array for:- // question_grouped_random_password() // ----------------------------------------------------------------- if ( ! array_key_exists( 'args' , $this_constraint ) ) { $options = array() ; } else { if ( ! is_array( $this_constraint['args'] ) ) { return << 4 , // 'chars_per_group' => 4 , // 'group_separator' => '-' , // 'lowercase_only' => TRUE // ) // // --- // // NOTE! // ----- // With some combinations, it depends very much on the FONT used (as to // how similar two different characters look). Thus the above rules are // a worst-case set. Stuff is in there if in any common (web) font, // the chance of confusion exists. // // RETURNS // On SUCCESS // TRUE or FALSE // // On FAILURE // $error_message STRING // ----------------------------------------------------------------------- $result = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_passwords\question_grouped_random_password( $new_or_existing_field_value , $options ) ; // ----------------------------------------------------------------- if ( is_string( $result ) ) { return $result ; } // ----------------------------------------------------------------- if ( $result !== TRUE ) { // $safe_new_or_existing_field_value = htmlentities( $new_or_existing_field_value ) ; $candidate = \greatKiwi_byFernTec_adSwapper_local_v0x1x211_passwords\generate_grouped_random_password( $options ) ; return << 'signed-integer' // 'args' => array( // 'min' => <1+ digits> // 'max' => <1+ digits> // 'question_optional' => TRUE/FALSE // ) // // "instance", if specified, is ignored // ) // // A STRING, INT or FLOAT that's digits only - with // // optional leading minus sign. If either "min" and/or // // "max" are not specified or NULL/FALSE/empty string, // // then NO such "min"/"max" applies. // // ----------------------------------------------------------------- // ------------------------------------------------------------------------- // is_signed_slash_unsigned_integer( // $caller_apps_includes_dir , // $new_or_existing_field_value , // $this_constraint , // $question_signed , // $adding_editing , // $safe_dataset_title , // $safe_array_storage_field_title , // $safe_array_storage_field_slug // ) // - - - - - - - - - - - - - - - - - - - // RETURNS // On SUCCESS // ARRAY( $str_value STRING ) // Where $str_value is $new_or_existing field value converted // to a (signed integer) STRING // // On FAILURE // $error_message STRING // ------------------------------------------------------------------------- $question_signed = TRUE ; // ----------------------------------------------------------------- $str_value = is_signed_slash_unsigned_integer( $caller_apps_includes_dir , $new_or_existing_field_value , $this_constraint , $question_signed , $adding_editing , $safe_dataset_title , $safe_array_storage_field_title , $safe_array_storage_field_slug ) ; // ----------------------------------------------------------------- if ( is_string( $str_value ) ) { return $str_value ; } // ----------------------------------------------------------------- continue ; // ----------------------------------------------------------------- } elseif ( $this_constraint['method'] === 'unsigned-integer' ) { // ================================================================= // FIELD CONSTRAINT = "UNSIGNED-INTEGER" // ================================================================= // ----------------------------------------------------------------- // Here we should have (eg):- // // $this_constraint = array( // 'method' => 'unsigned-integer' // 'args' => array( // 'min' => <1+ digits> // 'max' => <1+ digits> // 'question_optional' => TRUE/FALSE // ) // // "instance", if specified, is ignored // ) // // A STRING, INT or FLOAT that's digits only (and has NO // // leading minus sign). If either "min" and/or "max" are // // not specified or NULL/FALSE/empty string, then NO such // // "min"/"max" applies. // // ----------------------------------------------------------------- // ------------------------------------------------------------------------- // is_signed_slash_unsigned_integer( // $caller_apps_includes_dir , // $new_or_existing_field_value , // $this_constraint , // $question_signed , // $adding_editing , // $safe_dataset_title , // $safe_array_storage_field_title , // $safe_array_storage_field_slug // ) // - - - - - - - - - - - - - - - - - - - // RETURNS // On SUCCESS // ARRAY( $str_value STRING ) // Where $str_value is $new_or_existing field value converted // to a (signed integer) STRING // // On FAILURE // $error_message STRING // ------------------------------------------------------------------------- $question_signed = FALSE ; // ----------------------------------------------------------------- $str_value = is_signed_slash_unsigned_integer( $caller_apps_includes_dir , $new_or_existing_field_value , $this_constraint , $question_signed , $adding_editing , $safe_dataset_title , $safe_array_storage_field_title , $safe_array_storage_field_slug ) ; // ----------------------------------------------------------------- if ( is_string( $str_value ) ) { return $str_value ; } // ----------------------------------------------------------------- continue ; // ----------------------------------------------------------------- } elseif ( $this_constraint['method'] === 'dashed-name' ) { // ================================================================= // FIELD CONSTRAINT = "DASHED-NAME" // ================================================================= // ----------------------------------------------------------------- // Here we should have (eg):- // // $this_constraint = array( // 'method' => 'dashed-name' // // "args" and "instance", if specified, are ignored // ) // // ----------------------------------------------------------------- // ----------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_stringUtils\ // ctype_dashed_name( $value ) // - - - - - - - - - - - - - - // Lowercase alphanumeric characters and dash only. // No leading, trailing or double dashes. // No leading numerics (perhaps not necessary - but let's be safe) // // RETURNS // TRUE or FALSE // ----------------------------------------------------------------------- if ( ! \greatKiwi_byFernTec_adSwapper_local_v0x1x211_stringUtils\ctype_dashed_name( $new_or_existing_field_value ) ) { // $safe_new_or_existing_field_value = htmlentities( $new_or_existing_field_value ) ; return << 'notags' // // "args" and "instance", if specified, are ignored // ) // // ----------------------------------------------------------------- // ------------------------------------------------------------------------- // string strip_tags ( string $str [, string $allowable_tags ] ) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // This function tries to return a string with all NULL bytes, HTML and PHP // tags stripped from a given str. It uses the same tag stripping state // machine as the fgetss() function. // // str // The input string. // // allowable_tags // You can use the optional second parameter to specify tags which // should not be stripped. // // Note: HTML comments and PHP tags are also stripped. This is // hardcoded and can not be changed with allowable_tags. // // Note: This parameter should not contain whitespace. // strip_tags() sees a tag as a case-insensitive string // between < and the first whitespace or >. It means that // strip_tags("
", "
") returns an empty string. // // Returns the stripped string. // // (PHP 4, PHP 5) // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $new_or_existing_field_value ) ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( htmlentities( $new_or_existing_field_value ) ) ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( \strip_tags( $new_or_existing_field_value ) ) ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( htmlentities( \strip_tags( $new_or_existing_field_value ) ) ) ; //exit() ; if ( \strip_tags( $new_or_existing_field_value ) !== $new_or_existing_field_value ) { return << 'sequential-id' , // 'args' => array( // 'or_empty_string' => TRUE / FALSE // 'or_blank_string' => TRUE / FALSE // ) // ) // // ----------------------------------------------------------------- $or_empty_string = FALSE ; $or_blank_string = FALSE ; // ----------------------------------------------------------------- if ( array_key_exists( 'args' , $this_constraint ) ) { // ------------------------------------------------------------- if ( ! is_array( $this_constraint['args'] ) ) { return << 1 ) { return << 0 ) { return << 0 ) { return << 0 ) { return << array( // 'allowed_types' => array( 'boolean' ) , // 'default_value' => FALSE // ) // 'asterisk_means_all' => array( // 'allowed_types' => array( 'boolean' ) , // 'default_value' => FALSE // ) // ) // // RETURNS // o On SUCCESS // TRUE // // o On FAILURE // $error_message STRING // ------------------------------------------------------------------------- if ( ! array_key_exists( 'args' , $this_constraint ) ) { $this_constraint['args'] = $expected_members_and_their_defaults ; return TRUE ; } //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $this_constraint ) ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $expected_members_and_their_defaults ) ; // ------------------------------------------------------------------------- $ns = __NAMESPACE__ ; $fn = __FUNCTION__ ; // ------------------------------------------------------------------------- if ( ! is_array( $this_constraint['args'] ) ) { return << $expected_details ) { // --------------------------------------------------------------------- if ( array_key_exists( $expected_name , $this_constraint['args'] ) ) { // ----------------------------------------------------------------- $args_value = $this_constraint['args'][ $expected_name ] ; // ----------------------------------------------------------------- $args_values_type = \gettype( $args_value ) ; // ----------------------------------------------------------------- if ( ! in_array( $args_values_type , $expected_details['allowed_types'] , TRUE ) ) { return << $actual_value ) { // --------------------------------------------------------------------- if ( ! array_key_exists( $actual_name , $expected_members_and_their_defaults ) ) { $safe_actual_name = htmlentities( $actual_name ) ; return <<