prefix variable. (If // you're developing for a version of WordPress older than 2.0, you'll // need to use the $table_prefix global variable, which is deprecated in // version 2.1)." // // ------------------------------------------------------------------------- return \greatKiwi_byFernTec_adSwapper_local_v0x1x210_basepressMysql\prepend_wordpress_table_name_prefix( 'great_kiwi_sequential_ids' ) ; // ------------------------------------------------------------------------- } // ============================================================================= // get_new_sequential_record_id() // ============================================================================= function get_new_sequential_record_id( $core_plugapp_dirs ) { // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x210_sequentialIdsSupport\ // get_new_sequential_record_id( // $core_plugapp_dirs // ) // - - - - - - - - - - - - - - - // Returns a sequential ID in the range:- // 1 to 18,446,744,073,709,551,615 (= MySQL unsigned BIGINT max) // // RETURNS // On SUCCESS // $sequential_id STRING // // On FAILURE // ARRAY( $error_message STRING ) // ------------------------------------------------------------------------- // ========================================================================= // Init. // ========================================================================= $ns = __NAMESPACE__ ; $fn = __FUNCTION__ ; // ------------------------------------------------------------------------- global $wpdb ; // ========================================================================= // LOAD the MYSQL SUPPORT... // ========================================================================= require_once( $core_plugapp_dirs['plugins_includes_dir'] . '/basepress-mysql.php' ) ; // ========================================================================= // Configure the MYSQL ERROR HANDLING... // ========================================================================= // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x210_basepressMysql\set_error_handling( // $level , // $question_die_on_error // ) // - - - - - - - - - - - - - - - - - - // Sets:- // $GLOBALS['BASEPRESS']['MYSQL']['error_level'] // $GLOBALS['BASEPRESS']['MYSQL']['question_die_on_error'] // // to the specified values. // // $level must be one of:- // // 'none' // NO error messages at all // // 'user' // Simple generic error messages // // suitable for front-end where you // // want to keep any info. that might // // assist hackers to a minimum. // // 'developer' // Detailed error messages (as much // // info. as possible. // // $question_die_on_error must be TRUE or FALSE. // // RETURNS // On SUCCESS // - - - - - // TRUE // // On FAILURE // - - - - - // $error_message STRING // ------------------------------------------------------------------------- // $level = 'user' ; // // $question_die_on_error = FALSE ; // // // ------------------------------------------------------------------------- // // $result = \greatKiwi_byFernTec_adSwapper_local_v0x1x210_basepressMysql\set_error_handling( // $level , // $question_die_on_error // ) ; // // // ------------------------------------------------------------------------- // // if ( $result !== TRUE ) { // return array( $result ) ; // } // Assumed already done // ========================================================================= // GET the SEQUENTIAL IDs TABLE NAME... // ========================================================================= $sequential_ids_table_name = get_sequential_ids_table_name() ; // ========================================================================= // DOES the SEQUENTIAL IDS TABLE EXIST ? // // If NOT, CREATE it... // ========================================================================= // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x210_basepressMysql\table_exists( // $table_name // ) // - - - - - - - - - - - - - - - // RETURNS TRUE or FALSE, depending on whether the table exists or not. // // NOTE! // ----- // $table_name is an ABSOLUTE table name - with the WordPress table // prefix prepended if necessary. // // Call:- // // table_exists( // prepend_wordpress_table_name_prefix( $table_name ) // ) // // if you want to supply the table name WITHOUT the WordPress table prefix // (and have that prefix automatically prepended for you). // ------------------------------------------------------------------------- if ( \greatKiwi_byFernTec_adSwapper_local_v0x1x210_basepressMysql\table_exists( $sequential_ids_table_name ) !== TRUE ) { // ===================================================================== // CREATE "SEQUENTIAL IDS" TABLE // ===================================================================== // --------------------------------------------------------------------- // Create the table... // --------------------------------------------------------------------- $sql = <<query( $sql ) ; // The function returns an integer // corresponding to the number of rows // affected/selected. If there is a // MySQL error, the function will // return FALSE. // --------------------------------------------------------------------- if ( $number_records_affected === FALSE ) { $msg = <<query() // // seems to return TRUE (ie; it returns the boolean value "1"). // --------------------------------------------------------------------- //pr( $number_records_affected ) ; //echo "\n" , gettype( $number_records_affected ) , "\n" ; // --------------------------------------------------------------------- if ( gettype( $number_records_affected ) !== 'boolean' || $number_records_affected != 1 ) { $msg = <<query( $sql ) ; // The function returns an integer // corresponding to the number of rows // affected/selected. If there is a // MySQL error, the function will // return FALSE. // --------------------------------------------------------------------- if ( $number_records_affected === FALSE ) { $msg = <<query() // // seems to return TRUE (ie; it returns the boolean value "1"). // --------------------------------------------------------------------- //pr( $number_records_affected ) ; //echo "\n" , gettype( $number_records_affected ) , "\n" ; // --------------------------------------------------------------------- if ( gettype( $number_records_affected ) !== 'boolean' || $number_records_affected != 1 ) { $msg = << "414243313233" // // hex_encode( 'The quick brown fox...' ) // ==> "54686520717569636b2062726f776e20666f782e2e2e" // // NOTES! // ------ // 1. hex_encode() will handle all character/byte values, from ASCII 0 // to ASCII 255. Ie:- // // hex_encode( chr(0) . chr(1) . chr(2) . chr(253) . chr(254) . chr(255) ) // ==> "000102fdfeff" (= "00 01 02 fd fe ff") // // In other words, hex_encode() will happily encode PHP strings that // contain binary data. // // 2. The encoded string contains only the chars:- // o "0" to "9", and; // o "a" to "f" // // Thus, it may safely be:- // o Included in a URL query string, // o Inserted into a MySQL database query, and; // o Stored directly into a MySQL database (it contains only // alphanumeric characters - so there's no need for any // escaping, etc). // // 3. To decode the encoded string, use hex_decode(). // // 4. From the PHP Manual, "Strings" section... // // "A string is series of characters. Before PHP 6, a character // is the same as a byte. That is, there are exactly 256 // different characters possible. This also implies that PHP // has no native support of Unicode. See utf8_encode() and // utf8_decode() for some basic Unicode functionality. // // Note: It is no problem for a string to become very large. // PHP imposes no boundary on the size of a string; the // only limit is the available memory of the computer // on which PHP is running." // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x210_basepressMysql\ // get_zero_or_more_records( // $sql // ) // - - - - - - - - - - - - - - - - - - - - - // NOTES! // ====== // 1. The INPUT $sql should NOT be escaped. // // 2. MySQL Data Types AREN'T PRESERVED! // ---------------------------------- // In other words, something stored in the DB as a MySQL INT, WON'T // necessarily be returned as a PHP INT. It comes back as a STRING. // // I haven't checked FLOATs and TIMESTAMPS, etc. But I assume that // the same applies to them. // // Why this happens I'm not sure. But presumably, since we access // the database with the WordPress Wpdb class - it's that class's // fault. // // RETURNS // On SUCCESS // - - - - - // The 0+ records specified by the SQL string (as a PHP numeric // array of records). Eg:- // // $records = array( // 0 => array( // 'field_name_1' => , // 'field_name_2' => , // ... ... // 'field_name_N' => // ) // ... // ) // // On FAILURE // - - - - - // An error message STRING. // ------------------------------------------------------------------------- while ( TRUE ) { // --------------------------------------------------------------------- $random = \greatKiwi_byFernTec_adSwapper_local_v0x1x210_random\secure_rand( 64 ) ; // --------------------------------------------------------------------- $random = \greatKiwi_byFernTec_adSwapper_local_v0x1x210_stringUtils\hex_encode( $random ) ; // --------------------------------------------------------------------- $sql = << , // ... // 'field_name_N' => // ) // // In other words, $raw_record_data must be an associative ARRAY of // field name => field_value // // pairs. Where:- // // 1. At least ONE field must be specified. // // 2. Field values can be any of the following PHP data types:- // STRING // INT // FLOAT // TRUE (stored as 1 in the DB) // FALSE (stored as 0 in the DB) // NULL (stored as NULL in the DB) // // PHP ARRAY and OBJECT type fields AREN'T allowed. // // 3. You DON'T have to supply INT and FLOAT values as PHP // INTs or FLOATS. They can be supplied as PHP STRINGS // (eg; from $_GET and/or $_POST). And MySQL will // automatically convert them (before storing them). // // NOTE! // ----- // Every value that "add_record()" supplies to MySQL will // be supplied in STRING format. So putting (eg):- // $_GET['id'] // // into $raw_record_data like:- // $raw_record_data['id'] = (int) $_GET['id'] // // is pointless. Since "add_record()" will simply do:- // (string) $raw_record_data['id'] // // to it before supplying it to MySQL. // // 4. The field values MUST NOT be SQL escaped. You MUST supply // the RAW input data (even the raw $_GET and $_POST data // entered by the user). And "add_record()" will escape it // for you. // // --- // // RETURNS either:- // o The new record's record ID (as PHP INT) on SUCCESS // o An error message STRING on FAILURE // ------------------------------------------------------------------------- $raw_record_data = array( 'random' => $random ) ; // ------------------------------------------------------------------------- $result = \greatKiwi_byFernTec_adSwapper_local_v0x1x210_basepressMysql\add_record( $sequential_ids_table_name , $raw_record_data ) ; // ------------------------------------------------------------------------- if ( is_string( $result ) ) { return array( $result ) ; } // ========================================================================= // Get the BIGINT ID by having MySQL cast it to a string, before // returning it. // // This is to prevent problems with PHP not being able to handle BIGINTs // properly... // ========================================================================= $sql = << Array( // [CAST( CAST( id AS UNSIGNED ) AS CHAR( 100 ) )] => 2 // ) // ) // // ------------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x210_testDebug\pr( $result ) ; $sid = array_values( $result[0] ) ; $sid = $sid[0] ; // ------------------------------------------------------------------------- if ( ! is_string( $sid ) ) { $msg = <<get_var( $sql ) ; // The get_var function returns a single variable from the database. // Though only one variable is returned, the entire result of the query // is cached for later use. Returns NULL if no result is found. // ------------------------------------------------------------------------- if ( $count === NULL ) { $msg = << 100 ) { // --------------------------------------------------------------------- // Delete all but the last 10 records... // --------------------------------------------------------------------- $sql = << Array( // [datetime_created] => 2014-12-12 15:03:38 // ) // [1] => Array( // [datetime_created] => 2014-12-12 18:44:19 // ) // ... // [10] => Array( // [datetime_created] => 2014-12-12 19:01:46 // ) // ) // // --------------------------------------------------------------------- //\greatKiwi_byFernTec_adSwapper_local_v0x1x210_testDebug\pr( $result , '$result' ) ; // --------------------------------------------------------------------- // Get the index of the total - 10th record... // --------------------------------------------------------------------- $index_to_delete_to = count( $result ) - 9 ; // --------------------------------------------------------------------- // Delete this record and before... // --------------------------------------------------------------------- $sql = <<query( $sql ) ; // The function returns an integer // corresponding to the number of rows // affected/selected. If there is a // MySQL error, the function will // return FALSE. // --------------------------------------------------------------------- if ( $number_records_affected === FALSE ) { $msg = <<query() // // seems to return TRUE (ie; it returns the boolean value "1"). // --------------------------------------------------------------------- //pr( $number_records_affected ) ; //echo "\n" , gettype( $number_records_affected ) , "\n" ; // --------------------------------------------------------------------- // if ( gettype( $number_records_affected ) !== 'boolean' // || // $number_records_affected != $number_records_to_delete // ) { // // $msg = << 'd' // '1' => 'n' // '2' => '2' // '3' => '3' // '4' => '4' // '5' => 'p' // '6' => 'x' // '7' => '7' // '8' => 'y' // '9' => '9' // ) // // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // WARNING! // ======== // NEVER CHANGE THIS CODE (unless you know what you're doing). // // Or else you won't be able to reverse sequential keys already generated // back to their original numeric form (correctly). // ------------------------------------------------------------------------- return array( '0' => 'd' , '1' => 'n' , '2' => '2' , '3' => '3' , '4' => '4' , '5' => 'p' , '6' => 'x' , '7' => '7' , '8' => 'y' , '9' => '9' ) ; // ------------------------------------------------------------------------- } // ============================================================================= // get_number2key_pad_chars() // ============================================================================= function get_number2key_pad_chars() { // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x210_sequentialIdsSupport\ // get_number2key_pad_chars() // - - - - - - - - - - - - - // Returns a STRING like:- // // $pad_chars = 'cghkmvwz' // // Which string contains the "non-confusing" lower case alpha chars (as // described/defined in "great-kiwi-passwords.php") - less those that // appear as values in (the array returned by):- // get_number2key_conversion_table() // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // WARNING! // ======== // NEVER CHANGE THIS CODE (unless you know what you're doing). // // Or else you won't be able to reverse sequential keys already generated // back to their original numeric form (correctly). // ------------------------------------------------------------------------- $conversion_table = get_number2key_conversion_table() ; // ------------------------------------------------------------------------- $candidate_pad_chars = 'cdghkmnpvwxyz' ; // The non-confusing lower case alpha chars. // See "great-kiwi-passwords.php" // ------------------------------------------------------------------------- $len = strlen( $candidate_pad_chars ) ; $pad_chars = '' ; for ( $i=0 ; $i<$len ; $i++ ) { $char = $candidate_pad_chars[$i] ; if ( ! in_array( $char , $conversion_table , TRUE ) ) { $pad_chars .= $char ; } } // ------------------------------------------------------------------------- return $pad_chars ; // ------------------------------------------------------------------------- } // ============================================================================= // number2key() // ============================================================================= function number2key( $in ) { // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x210_sequentialIdsSupport\ // number2key( $in ) // - - - - - - - - - - - // Converts a "number" to a "key", by:- // // 1. Replacing certain digits with lower case alpha characters, as // follows:- // '0' => 'd' // '1' => 'n' // '2' => '2' // '3' => '3' // '4' => '4' // '5' => 'p' // '6' => 'x' // '7' => '7' // '8' => 'y' // '9' => '9' // // Where characters in the input string that aren't "0" to "9" // are discarded. // // 2. Padding the result out to:- // o Min 8 chars, and; // o An even multiple of 4 characters, then; // // 3. Inserting "-" (dash/hyphen) characters every 4 characters. Ie:- // "12" => "12" // "1234" => "1234" // "12345" => "1234-5" // "1234567" => "1234-567" // "12345678901" => "1234-5678-901" // etc // // EXAMPLES:- // "0" => "dczv-mwhk" // "10" => "ndcg-wkzm" // "100" => "nddc-kmwh" // "1000" => "nddd-vkmw" // "9150602" => "9npd-xd2h" // "566449429" => "pxx4-4942-9vwm" // "2143301808" => "2n43-3dny-dykm" // ... // // NOTES! // ====== // 1. If the input $number ISN'T a string, it's auto-converted to one. // // 2. The input number/string can be any length. // // 3. You can (losslessly) reverse the transformation with // "key2number()". // // 4. Because of the random padding characters used to pad the returned // key out to an even multiple of 4 chars per block, converting // the same number more than one can/should yield different results. // Ie:- // "12345" => "n234-pkzm" // "12345" => "n234-pwgh" // "12345" => "n234-pwkz" // "12345" => "n234-pczg" // "12345" => "n234-pgzv" // ... // ------------------------------------------------------------------------- $conversion_table = get_number2key_conversion_table() ; // ------------------------------------------------------------------------- $pad_chars = get_number2key_pad_chars() ; // ------------------------------------------------------------------------- $pad_chars = str_shuffle( $pad_chars ) ; // Add extra randomness // ------------------------------------------------------------------------- $in = (string) $in ; $len = strlen( $in ) ; $out = '' ; // ------------------------------------------------------------------------- for ( $i=0 ; $i<$len ; $i++ ) { $char = $in[$i] ; if ( array_key_exists( $char , $conversion_table ) ) { $out .= $conversion_table[ $char ] ; } } // ------------------------------------------------------------------------- $pad_chars_temp = $pad_chars ; while ( strlen( $out ) < 8 || ( strlen( $out ) % 4 ) !== 0 ) { if ( strlen( $pad_chars_temp ) <= 0 ) { $pad_chars_temp = $pad_chars ; } $index = mt_rand( 0 , strlen( $pad_chars_temp ) - 1 ) ; $char = substr( $pad_chars_temp , $index , 1 ) ; $out .= $char ; $pad_chars_temp = str_replace( $char , '' , $pad_chars_temp ) ; } // ------------------------------------------------------------------------- $chunks = str_split( $out , 4 ) ; $out = implode( '-' , $chunks ) ; // ------------------------------------------------------------------------- return $out ; // ------------------------------------------------------------------------- } // ============================================================================= // key2number() // ============================================================================= function key2number( $in ) { // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x210_sequentialIdsSupport\ // key2number( $in ) // - - - - - - - - - - - // Converts a "key" back to a "number", by:- // // 1. Removing any "-" (dash/hyphen) characters. // // Note! All dash/hyphens are removed (whether they're every 4 // characters or not. // // 2. Replacing certain digits with lower case alpha characters, as // follows:- // 'k' => '0' // 'n' => '1' // '2' => '2' // '3' => '3' // '4' => '4' // 'x' => '5' // 'y' => '6' // '7' => '7' // 'z' => '8' // '9' => '9' // // Where any characters in the input string that aren't one of // those to be converted (back to digits), are discarded. // // NOTE! If the input $number ISN'T a string, it's auto-converted to one. // ------------------------------------------------------------------------- $in = (string) $in ; $len = strlen( $in ) ; $conversion_table = array_flip( get_number2key_conversion_table() ) ; $out = '' ; // ------------------------------------------------------------------------- for ( $i=0 ; $i<$len ; $i++ ) { $char = $in[$i] ; if ( array_key_exists( $char , $conversion_table ) ) { $out .= $conversion_table[ $char ] ; } } // ------------------------------------------------------------------------- return $out ; // ------------------------------------------------------------------------- } // ============================================================================= // get_new_sequential_id() // ============================================================================= function get_new_sequential_id( $core_plugapp_dirs ) { // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x210_sequentialIdsSupport\ // get_new_sequential_id( // $core_plugapp_dirs // ) // - - - - - - - - - - - - // Returns a new Ad Swapper sequential ID - in "key" format. Eg:- // "dczv-mwhk" // "pxx4-4942-9vwm" // ... // // RETURNS // On SUCCESS // $sid STRING // // On FAILURE // ARRAY( $error_message STRING ) // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x210_sequentialIdsSupport\ // get_new_sequential_record_id( // $core_plugapp_dirs // ) // - - - - - - - - - - - - - - - // Returns a sequential ID in the range:- // 1 to 18,446,744,073,709,551,615 (= MySQL unsigned BIGINT max) // // RETURNS // On SUCCESS // $sequential_id STRING // // On FAILURE // ARRAY( $error_message STRING ) // ------------------------------------------------------------------------- $sid = get_new_sequential_record_id( $core_plugapp_dirs ) ; // ------------------------------------------------------------------------- if ( is_array( $sid ) ) { return $sid ; } // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x210_sequentialIdsSupport\ // number2key( $in ) // - - - - - - - - - - - // Converts a "number" to a "key", by:- // // 1. Replacing certain digits with lower case alpha characters, as // follows:- // '0' => 'd' // '1' => 'n' // '2' => '2' // '3' => '3' // '4' => '4' // '5' => 'p' // '6' => 'x' // '7' => '7' // '8' => 'y' // '9' => '9' // // Where characters in the input string that aren't "0" to "9" // are discarded. // // 2. Padding the result out to:- // o Min 8 chars, and; // o An even multiple of 4 characters, then; // // 3. Inserting "-" (dash/hyphen) characters every 4 characters. Ie:- // "12" => "12" // "1234" => "1234" // "12345" => "1234-5" // "1234567" => "1234-567" // "12345678901" => "1234-5678-901" // etc // // EXAMPLES:- // "0" => "dczv-mwhk" // "10" => "ndcg-wkzm" // "100" => "nddc-kmwh" // "1000" => "nddd-vkmw" // "9150602" => "9npd-xd2h" // "566449429" => "pxx4-4942-9vwm" // "2143301808" => "2n43-3dny-dykm" // ... // // NOTES! // ====== // 1. If the input $number ISN'T a string, it's auto-converted to one. // // 2. The input number/string can be any length. // // 3. You can (losslessly) reverse the transformation with // "key2number()". // // 4. Because of the random padding characters used to pad the returned // key out to an even multiple of 4 chars per block, converting // the same number more than one can/should yield different results. // Ie:- // "12345" => "n234-pkzm" // "12345" => "n234-pwgh" // "12345" => "n234-pwkz" // "12345" => "n234-pczg" // "12345" => "n234-pgzv" // ... // ------------------------------------------------------------------------- return number2key( $sid ) ; // ------------------------------------------------------------------------- } // ============================================================================= // get_new_sequential_id_thats_unique_in_dataset() // ============================================================================= function get_new_sequential_id_thats_unique_in_dataset( $core_plugapp_dirs , $dataset_details , $max_attempts = 1 ) { // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x210_sequentialIdsSupport\ // get_new_sequential_id_thats_unique_in_dataset( // $core_plugapp_dirs , // $dataset_details , // $max_attempts = 1 // ) // - - - - - - - - - - - - - - - // Returns a new Ad Swapper sequential ID - in "key" format. Eg:- // "dczv-mwhk" // "pxx4-4942-9vwm" // ... // // And checks that the returned SID is the only one for the given // dataset and field. The routine will keep trying to find a unique // SID, up to the specified max number of attempts. // // $dataset_details can be either:- // // $dataset_details = array( // 'dataset_title' => "xxx" , // 'dataset_records' => array(...) , // 'field_slug' => xxx" // ) // // (if the new SID must be unique in exactly one dataset) // // Or:- // // $dataset_details = array( // array( // 'dataset_title' => "xxx" , // 'dataset_records' => array(...) , // 'field_slug' => xxx" // ) , // ... // array( // 'dataset_title' => "xxx" , // 'dataset_records' => array(...) , // 'field_slug' => xxx" // ) // ) // // (if the new SID must be unique in two or more datasets) // // RETURNS // On SUCCESS // $sid STRING // // On FAILURE // ARRAY( $error_message STRING ) // ------------------------------------------------------------------------- // ========================================================================= // Init. // ========================================================================= $ns = __NAMESPACE__ ; $fn = __FUNCTION__ ; // ========================================================================= // Convert the:- // // $dataset_details = array( // 'dataset_title' => "xxx" , // 'dataset_records' => array(...) , // 'field_slug' => xxx" // ) // // form to the:- // // $dataset_details = array( // array( // 'dataset_title' => "xxx" , // 'dataset_records' => array(...) , // 'field_slug' => xxx" // ) , // ... // array( // 'dataset_title' => "xxx" , // 'dataset_records' => array(...) , // 'field_slug' => xxx" // ) // ) // // form (so that from now on, we can process them both the same way). // ========================================================================= if ( array_key_exists( 'dataset_title' , $dataset_details ) ) { $dataset_details = array( $dataset_details ) ; } // ========================================================================= // Generate the:- // 'safe_dataset_title' // 'safe_field_slug' // // for all datasets... // ========================================================================= foreach ( $dataset_details as $this_index => $this_dataset ) { $dataset_details[ $this_index ]['safe_dataset_title'] = htmlentities( $this_dataset['dataset_title'] ) ; $dataset_details[ $this_index ]['safe_field_slug'] = htmlentities( $this_dataset['field_slug'] ) ; } // ========================================================================= // Search for the requested unique SID... // ========================================================================= $number_attempts = 0 ; // ------------------------------------------------------------------------- while ( TRUE ) { // ------------------------------------------------------------------------- // \greatKiwi_byFernTec_adSwapper_local_v0x1x210_sequentialIdsSupport\ // get_new_sequential_id( // $core_plugapp_dirs // ) // - - - - - - - - - - - - // Returns a new Ad Swapper sequential ID - in "key" format. Eg:- // "dczv-mwhk" // "pxx4-4942-9vwm" // ... // // RETURNS // On SUCCESS // $sid STRING // // On FAILURE // ARRAY( $error_message STRING ) // ------------------------------------------------------------------------- // ===================================================================== // Make sure the page doesn't lock up (if we seem to be having // trouble generating a unique SID)... // ===================================================================== if ( $number_attempts >= $max_attempts ) { // TODO !!! // // Send warning email to Ad Swapper Central admin. $msg = << $this_dataset ) { // ----------------------------------------------------------------- // Does the SID exist in this dataset ? // ----------------------------------------------------------------- foreach ( $this_dataset['dataset_records'] as $this_record ) { // ------------------------------------------------------------- if ( ! array_key_exists( $this_dataset['field_slug'] , $this_record ) ) { $msg = <<