] // // RETURNS:- // On SUCCESS // NULL means there are NO mysql array storage key field overrides // --OR-- // $key_field_details = array( // 'slug' => "xxx" , // 'format' => "yyy" , // 'value' => "zzz" , // 'fail_link_creation_silently' => TRUE/FALSE , // 'url_encode_function_name' => "" | "aaa" , // 'url_decode_function_name' => "" | "bbb" // ) // // Where:- // // o $key_field_details['format'] is one of:- // -- OLD VERSION // # "sequential-id" (default) // # "ctype-digit" // # "great-kiwi-password" // -- NEW VERSION // # "mysql-bigint-id" (default) // # "sequential-id" // # "great-kiwi-password" // # "url" // # "custom-function" // // o $key_field_details['value'] is the (validated and ok) // value from the specified dataset record. // // o $key_field_details['fail_link_creation_silently'] means // that the key field contained NO value - but instead of // issuing an error, the caller should just NOT create // the "edit"/"delete" record link. // // o $key_field_details['url_encode_function_name']:- // -- Can be the empty string (if NO key field url encode // function is to be used). // -- If other than the empty string, then the specified // function exists. // // o $key_field_details['url_decode_function_name']:- // -- Can be the empty string (if NO key field url decode // function is to be used). // -- If other than the empty string, then the specified // function exists. // // On FAILURE // $error_message STRING // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // OVERVIEW // ======== // For use with tables that are stored in a MySql database (as opposed to // array storage). // // In this case, instead of having a record like (eg):- // // array( // 'created_server_datetime_utc' => xxx // 'last_modified_server_datetime_utc' => xxx // // 'key' => xxx // DELETED // // 'target_site_url' => xxx // 'start_year_utc' => xxx // 'start_month_utc' => xxx // 'start_day_utc' => xxx // 'end_year_utc' => xxx // 'end_month_utc' => xxx // 'end_day_utc' => xxx // ) // // we have a record like (eg):- // // array( // 'id' => xxx // ADDED // 'created_server_datetime' => xxx // ADDED // 'last_modified_server_datetime' => xxx // ADDED // // 'created_server_datetime_utc' => xxx // 'last_modified_server_datetime_utc' => xxx // // 'target_site_url' => xxx // 'start_year_utc' => xxx // 'start_month_utc' => xxx // 'start_day_utc' => xxx // 'end_year_utc' => xxx // 'end_month_utc' => xxx // 'end_day_utc' => xxx // ) // // The big change is that the "key" field disappears, and is replaced by // the "id" field. // // Which affects "edit" and "delete" record selection. // // Since the "record_key" GET variable can no longer hold the contents // of the record to be edited/deleted's "key" field. Instead, some other // field must be used. // // We could just default to the "id" field. But to give more flexibility, // we allow the dataset definer to specify the field to be used. // // OLD SYSTEM // ---------- // Was like (eg):- // // $dataset_details = array( // ... // 'dataset_slug' => 'ad_swapper_central_site_registrations' , // ... // 'array_storage_key_field_slug' => 'key' , // ... // 'storage_method' => 'mysql' , // "array-storage" or "mysql" // ... // 'mysql_overrides' => array( // 'array_storage_key_field_slug' => 'ad_swapper_site_sid' , // 'key_field_format' => 'sequential-id' , // 'key_field_format_args' => NULL , // 'fail_link_creation_silently_on_empty_record_key' => TRUE // ) // ... // ) // // Where "key_field_format" could be one of:- // o "sequential-id" (default) // o "ctype-digit" // o "great-kiwi-password" // // The old system wasn't fully implemented (and was partially broken). // // It's retained for backward compatability (to eliminate the need to // update the old applications/plugins that use it). // // NEW SYSTEM // ---------- // Is (eg):- // // $dataset_details = array( // ... // 'dataset_slug' => 'ad_swapper_central_manual_registrations' , // ... // 'array_storage_key_field_slug' => 'key' , // ... // 'storage_method' => 'mysql' , // "array-storage" or "mysql" // ... // 'mysql_overrides' => array( // 'array_storage_key_field' => array( // 'slug' => 'id' , // 'format' => 'mysql-bigint-id' , // 'format_args' => array() , // // 'custom_validation_function_name' => '' , // 'fail_link_creation_silently_on_empty_record_key' => FALSE , // 'url_encode_function_name' => '' , // 'url_decode_function_name' => '' // ) // ) // // ) // // Where:- // // 1. "format" can be one of:- // -- "mysql-bigint-id" (default) // -- "sequential-id" // -- "great-kiwi-password" // -- "url" // -- "custom-function" // // 2. "format_args" is "format" dependent, as follows:- // // -- "mysql-bigint-id" // NOT USED // // -- "sequential-id" // NOT USED // // -- "great-kiwi-password" // $options array as required by:- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_passwords\question_grouped_random_password() // // -- "url" // array( // 'minlen' => N --or-- "default" = 10 // 'maxlen' => N --or-- "default" = 2000 // ) // // -- "custom_function" // Array of parameters (for the called function), as // required by:- // call_user_func_array() // // 3. "custom_validation_function_name" is only required if:- // "format" = "custom-function" // // The new system should be used for all new applications/plugins. // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $dataset_record_data , '$dataset_record_data' ) ; // ========================================================================= // Init. // ========================================================================= $ns = __NAMESPACE__ ; $fn = __FUNCTION__ ; // ========================================================================= // Storage Method Dependent... // ========================================================================= if ( array_key_exists( 'storage_method' , $selected_datasets_dmdd ) ) { $storage_method = $selected_datasets_dmdd['storage_method'] ; } else { $storage_method = 'array-storage' ; } // ------------------------------------------------------------------------- if ( $storage_method === 'array-storage' ) { // ===================================================================== // ARRAY-STORAGE // ===================================================================== return NULL ; // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- if ( $storage_method !== 'mysql' ) { return << "xxx" , // 'format' => "yyy" , // 'value' => "zzz" , // 'fail_link_creation_silently' => TRUE/FALSE // ) // // --------------------------------------------------------------------- $result['url_encode_function_name'] = '' ; $result['url_decode_function_name'] = '' ; // --------------------------------------------------------------------- return $result ; // --------------------------------------------------------------------- } // ========================================================================= // NEW VERSION // ========================================================================= $key_field_details = $selected_datasets_dmdd['mysql_overrides']['array_storage_key_field'] ; //\greatKiwi_byFernTec_adSwapper_local_v0x1x211_testDebug\pr( $key_field_details , '$key_field_details' ) ; // ========================================================================= // ERROR CHECKING // ========================================================================= // ------------------------------------------------------------------------- // slug ? // ------------------------------------------------------------------------- if ( ! array_key_exists( 'slug' , $key_field_details ) ) { return << 0 && bccomp( $key_field_value , $bigint_unsigned_max ) <= 0 ) { $key_field_ok = TRUE ; } // --------------------------------------------------------------------- } elseif ( $key_field_format === 'sequential-id' ) { // --------------------------------------------------------------------- require_once( $caller_apps_includes_dir . '/sequential-ids-support.php' ) ; // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_sequentialIdsSupport\ // question_sequential_id( // $candidate_sid // ) // - - - - - - - - - - - - // Determines whether or not $candidate_sid looks like a sequential ID // as generated by (eg):- // get_new_sequential_id() // get_new_sequential_id_thats_unique_in_dataset() // // or not. And returns TRUE or FALSE accordingly. // // In other words, $candidate_sid must be something like (eg):- // "dczv-mwhk" // "9npd-xd2h" // "pxx4-4942-9vwm" // "2n43-3dny-dykm" // etc... // ------------------------------------------------------------------------- if ( \greatKiwi_byFernTec_adSwapper_local_v0x1x211_sequentialIdsSupport\question_sequential_id( $key_field_value ) === TRUE ) { $key_field_ok = TRUE ; } // --------------------------------------------------------------------- } elseif ( $key_field_format === 'great-kiwi-password' ) { // --------------------------------------------------------------------- if ( array_key_exists( 'format_args' , $key_field_details ) ) { $key_field_format_args = $key_field_details['format_args'] ; } else { $key_field_format_args = array() ; } // --------------------------------------------------------------------- if ( ! is_array( $key_field_format_args ) ) { return << 4 , // 'chars_per_group' => 4 , // 'group_separator' => '-' , // 'lowercase_only' => TRUE , // 'question_punctuation' => FALSE // ) // // --- // // 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 // ----------------------------------------------------------------------- if ( \greatKiwi_byFernTec_adSwapper_local_v0x1x211_passwords\question_grouped_random_password( $key_field_value , $key_field_format_args ) === TRUE ) { $key_field_ok = TRUE ; } // --------------------------------------------------------------------- } elseif ( $key_field_format === 'url' ) { // --------------------------------------------------------------------- if ( array_key_exists( 'format_args' , $key_field_details ) ) { $key_field_format_args = $key_field_details['format_args'] ; if ( ! is_array( $key_field_format_args ) ) { return << 2 ) { return << "default"|N , "maxlen" => "default"|M ) expected) For dataset:  {$dataset_title} Detected in:  \\{$ns}\\{$fn}() EOT; } // --------------------------------------------------------------------- $minlen = $key_field_format_args['minlen'] ; // --------------------------------------------------------------------- if ( $minlen !== 'default' || ! is_int( $minlen ) || $minlen < 0 ) { return <<= 4.0.4, PHP 5) // // CHANGELOG // // Version Description // 5.3.0 The interpretation of object oriented keywords like parent and self has changed. Previously, calling them using the double colon syntax would emit an E_STRICT warning because they were interpreted as static. // // EXAMPLES // // Call the foobar() function with 2 arguments // call_user_func_array("foobar", array("one", "two")); // // As of PHP 5.3.0 // call_user_func_array(__NAMESPACE__ .'\Foo::test', array('Hannes')); // // As of PHP 5.3.0 // call_user_func_array(array(__NAMESPACE__ .'\Foo', 'test'), array('Philip')); // // Note: Before PHP 5.4, referenced variables in param_arr are passed to // the function by reference, regardless of whether the function // expects the respective parameter to be passed by reference. This // form of call-time pass by reference does not emit a deprecation // notice, but it is nonetheless deprecated, and has been removed // in PHP 5.4. Furthermore, this does not apply to internal // functions, for which the function signature is honored. Passing // by value when the function expects a parameter by reference // results in a warning and having call_user_func() return FALSE // (there is, however, an exception for passed values with // reference count = 1, such as in literals, as these can be turned // into references without ill effects — but also without writes // to that value having any effect —; do not rely in this // behavior, though, as the reference count is an implementation // detail and the soundness of this behavior is questionable). // // Note: Callbacks registered with functions such as call_user_func() and // call_user_func_array() will not be called if there is an // uncaught exception thrown in a previous callback. // ------------------------------------------------------------------------- return << $key_field_slug , 'format' => $key_field_format , 'value' => $key_field_value , 'fail_link_creation_silently' => $fail_link_creation_silently , 'url_encode_function_name' => $url_encode_function_name , 'url_decode_function_name' => $url_decode_function_name ) ; // ------------------------------------------------------------------------- } // ============================================================================= // is_valid_record_key() // ============================================================================= function is_valid_record_key( $caller_apps_includes_dir , $dataset_title , $selected_datasets_dmdd , $key_field_details , $key_field_value , $key_field_format ) { // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_standardDatasetManager\ // is_valid_record_key( // $caller_apps_includes_dir , // $dataset_title , // $selected_datasets_dmdd , // $key_field_details , // $key_field_value , // $key_field_format // ) // - - - - - - - - - - - - - - - - - // RETURNS // On SUCCESS // TRUE or FALSE // // On FAILURE // $error_message STRING // ------------------------------------------------------------------------- $ns = __NAMESPACE__ ; $fn = __FUNCTION__ ; // ========================================================================= // Storage Method Dependent... // ========================================================================= if ( array_key_exists( 'storage_method' , $selected_datasets_dmdd ) ) { $storage_method = $selected_datasets_dmdd['storage_method'] ; } else { $storage_method = 'array-storage' ; } // ------------------------------------------------------------------------- if ( $storage_method === 'array-storage' ) { // ===================================================================== // ARRAY-STORAGE // ===================================================================== require_once( $caller_apps_includes_dir . '/sequential-ids-support.php' ) ; // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_sequentialIdsSupport\ // question_sequential_id( // $candidate_sid // ) // - - - - - - - - - - - - // Determines whether or not $candidate_sid looks like a sequential ID // as generated by (eg):- // get_new_sequential_id() // get_new_sequential_id_thats_unique_in_dataset() // // or not. And returns TRUE or FALSE accordingly. // // In other words, $candidate_sid must be something like (eg):- // "dczv-mwhk" // "9npd-xd2h" // "pxx4-4942-9vwm" // "2n43-3dny-dykm" // etc... // ------------------------------------------------------------------------- return \greatKiwi_byFernTec_adSwapper_local_v0x1x211_sequentialIdsSupport\question_sequential_id( $key_field_value ) ; // --------------------------------------------------------------------- } // ------------------------------------------------------------------------- if ( $storage_method !== 'mysql' ) { return << 0 && bccomp( $key_field_value , $bigint_unsigned_max ) <= 0 ) { $key_field_ok = TRUE ; } // --------------------------------------------------------------------- } elseif ( $key_field_format === 'sequential-id' ) { // --------------------------------------------------------------------- require_once( $caller_apps_includes_dir . '/sequential-ids-support.php' ) ; // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x211_sequentialIdsSupport\ // question_sequential_id( // $candidate_sid // ) // - - - - - - - - - - - - // Determines whether or not $candidate_sid looks like a sequential ID // as generated by (eg):- // get_new_sequential_id() // get_new_sequential_id_thats_unique_in_dataset() // // or not. And returns TRUE or FALSE accordingly. // // In other words, $candidate_sid must be something like (eg):- // "dczv-mwhk" // "9npd-xd2h" // "pxx4-4942-9vwm" // "2n43-3dny-dykm" // etc... // ------------------------------------------------------------------------- if ( \greatKiwi_byFernTec_adSwapper_local_v0x1x211_sequentialIdsSupport\question_sequential_id( $key_field_value ) === TRUE ) { $key_field_ok = TRUE ; } // --------------------------------------------------------------------- } elseif ( $key_field_format === 'great-kiwi-password' ) { // --------------------------------------------------------------------- if ( array_key_exists( 'format_args' , $key_field_details ) ) { $key_field_format_args = $key_field_details['format_args'] ; } else { $key_field_format_args = array() ; } // --------------------------------------------------------------------- if ( ! is_array( $key_field_format_args ) ) { return << 4 , // 'chars_per_group' => 4 , // 'group_separator' => '-' , // 'lowercase_only' => TRUE , // 'question_punctuation' => FALSE // ) // // --- // // 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 // ----------------------------------------------------------------------- if ( \greatKiwi_byFernTec_adSwapper_local_v0x1x211_passwords\question_grouped_random_password( $key_field_value , $key_field_format_args ) === TRUE ) { $key_field_ok = TRUE ; } // --------------------------------------------------------------------- } elseif ( $key_field_format === 'ctype-digit' && $old_new === 'old' ) { // --------------------------------------------------------------------- if ( \ctype_digit( $key_field_value ) ) { $key_field_ok = TRUE ; } // --------------------------------------------------------------------- } elseif ( $key_field_format === 'url' && $old_new === 'new' ) { // --------------------------------------------------------------------- if ( array_key_exists( 'format_args' , $key_field_details ) ) { $key_field_format_args = $key_field_details['format_args'] ; if ( ! is_array( $key_field_format_args ) ) { return << 2 ) { return << "default"|N , "maxlen" => "default"|M ) expected) For dataset:  {$dataset_title} Detected in:  \\{$ns}\\{$fn}() EOT; } // --------------------------------------------------------------------- $minlen = $key_field_format_args['minlen'] ; // --------------------------------------------------------------------- if ( $minlen !== 'default' || ! is_int( $minlen ) || $minlen < 0 ) { return <<= 4.0.4, PHP 5) // // CHANGELOG // // Version Description // 5.3.0 The interpretation of object oriented keywords like parent and self has changed. Previously, calling them using the double colon syntax would emit an E_STRICT warning because they were interpreted as static. // // EXAMPLES // // Call the foobar() function with 2 arguments // call_user_func_array("foobar", array("one", "two")); // // As of PHP 5.3.0 // call_user_func_array(__NAMESPACE__ .'\Foo::test', array('Hannes')); // // As of PHP 5.3.0 // call_user_func_array(array(__NAMESPACE__ .'\Foo', 'test'), array('Philip')); // // Note: Before PHP 5.4, referenced variables in param_arr are passed to // the function by reference, regardless of whether the function // expects the respective parameter to be passed by reference. This // form of call-time pass by reference does not emit a deprecation // notice, but it is nonetheless deprecated, and has been removed // in PHP 5.4. Furthermore, this does not apply to internal // functions, for which the function signature is honored. Passing // by value when the function expects a parameter by reference // results in a warning and having call_user_func() return FALSE // (there is, however, an exception for passed values with // reference count = 1, such as in literals, as these can be turned // into references without ill effects — but also without writes // to that value having any effect —; do not rely in this // behavior, though, as the reference count is an implementation // detail and the soundness of this behavior is questionable). // // Note: Callbacks registered with functions such as call_user_func() and // call_user_func_array() will not be called if there is an // uncaught exception thrown in a previous callback. // ------------------------------------------------------------------------- return << ] // ------------------------------------------------------------------------- if ( is_string( $dataset_record_data ) ) { // --------------------------------------------------------------------- if ( ! array_key_exists( $dataset_record_data , $_GET ) ) { $safe_dataset_record_data = htmlentities( $dataset_record_data ) ; return << 4 , // 'chars_per_group' => 4 , // 'group_separator' => '-' , // 'lowercase_only' => TRUE , // 'question_punctuation' => FALSE // ) // // --- // // 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 // ----------------------------------------------------------------------- if ( \greatKiwi_byFernTec_adSwapper_local_v0x1x211_passwords\question_grouped_random_password( $key_field_value , $key_field_format_args ) === TRUE ) { $key_field_ok = TRUE ; } // --------------------------------------------------------------------- } else { // --------------------------------------------------------------------- return << $key_field_slug , 'format' => $key_field_format , 'value' => $key_field_value , 'fail_link_creation_silently' => $fail_link_creation_silently ) ; // ------------------------------------------------------------------------- } // ============================================================================= // That's that! // =============================================================================