gde_make_secure_url

Generate and store secure document link.

Description

(string) gde_make_secure_url( $url ); 

Returns (string)

Secure document link or false on failure

Parameters (1)

0. $url
The url.

Usage

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

Defined (1)

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

/libs/lib-secure.php  
  1. function gde_make_secure_url( $url ) { 
  2. global $wpdb; 
  3.  
  4. $table = $wpdb->prefix . 'gde_secure'; 
  5. $data = $wpdb->get_results( "SELECT * FROM $table WHERE url = '$url'", ARRAY_A ); 
  6.  
  7. if ( ! empty( $data ) ) { 
  8. // a secure url to this doc already exists 
  9. $data = $data[0]; 
  10. return $data['murl']; 
  11. } else { 
  12. // make a new entry 
  13. $newcode = gde_secure_code(); 
  14. $url_to_mask = GDE_PLUGIN_URL . "load.php?s=" . $newcode; 
  15. $masked_url = gde_get_short_url( $url_to_mask ); 
  16.  
  17. if ( ! $wpdb->insert( 
  18. $table,  
  19. array( 
  20. 'code' => $newcode,  
  21. 'url' => $url,  
  22. 'murl' => $masked_url 
  23. ),  
  24. array( 
  25. '%s', '%s', '%s' 
  26. ) ) { 
  27. gde_dx_log("Unable to record secure URL in database"); 
  28. return false; 
  29. } else { 
  30. return $masked_url;