gde_secure_code

Generate random document code.

Description

(string) gde_secure_code( (int) $length = 10 ); 

Returns (string)

Random string used for secure doc link in database

Parameters (1)

0. $length — Optional. (int) => 10
The length.

Usage

  1. if ( !function_exists( 'gde_secure_code' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-doc-embedder/libs/lib-secure.php'; 
  3.  
  4. // The length. 
  5. $length = 10; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = gde_secure_code($length); 
  9.  

Defined (1)

The function is defined in the following location(s).

/libs/lib-secure.php  
  1. function gde_secure_code( $length = 10 ) { 
  2. $alpha = 'aeioubdghjmnpqrstvyz'; 
  3. $alpha .= strtoupper( $alpha ); 
  4. $numer = '1234567890'; 
  5.  
  6. $code = ''; 
  7. $alt = time() % 2; 
  8. for ( $i = 0; $i < $length; $i++ ) { 
  9. if ( $alt == 1 ) { 
  10. $code .= $alpha[(rand() % strlen( $alpha ))]; 
  11. $alt = 0; 
  12. } else { 
  13. $code .= $numer[(rand() % strlen( $numer ))]; 
  14. $alt = 1; 
  15. return $code;