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
if ( !function_exists( 'gde_secure_code' ) ) { require_once ABSPATH . PLUGINDIR . 'google-doc-embedder/libs/lib-secure.php'; } // The length. $length = 10; // NOTICE! Understand what this does before running. $result = gde_secure_code($length);
Defined (1)
The function is defined in the following location(s).
- /libs/lib-secure.php
- function gde_secure_code( $length = 10 ) {
- $alpha = 'aeioubdghjmnpqrstvyz';
- $alpha .= strtoupper( $alpha );
- $numer = '1234567890';
- $code = '';
- $alt = time() % 2;
- for ( $i = 0; $i < $length; $i++ ) {
- if ( $alt == 1 ) {
- $code .= $alpha[(rand() % strlen( $alpha ))];
- $alt = 0;
- } else {
- $code .= $numer[(rand() % strlen( $numer ))];
- $alt = 1;
- }
- }
- return $code;
- }