Forum Discussion

Deleted_User_62's avatar
Deleted_User_62
Icon for Nimbostratus rankNimbostratus
Jul 07, 2015

APM Webtop Links - Getting PHP to run

Using the "Hosted Content" feature of the APM, I have uploaded some PHP files that allow me to generate Secure URLs pointing to our CDN hosted downloads. However, when I created a new Webtop Link (pointing to the PHP file) the PHP file shows up as text in the browser. When I click the webtop link, I want it to run the code and launch the secure URL. How do I get this PHP code to run? Code is posted below. (The hosted content includes another file cdn_secure.php that has the function called in the script.)

 

I also tried a portal link, but it downloaded the PHP file instead of running it.

 

This should be easy, right?

 

  • i can't a find a definite yes or no, but i think it just won't work. the documentation clearly doesn't mention php. all other things they do mention have a client side effect and don't require something on the host, that php would have. i would open a support case, easiest way to a certain answer, please do post the reply here.
  • I don't recognize the function cdn_gen_secure_uri, what is that supposed to do? You could possibly do this with an irule if you knew how the function generates the hash.

     

    If you can tell us what that does we might be able to help you find a way to make this work.

     

    Seth

     

  • Hi,

    Here is an iRule that should do the same thing as the php function.

    You would need to create a webtop link that points to APM HOSTNAME (example https://apm.hostname.com/file1) and add it to the webtop. You will want some other checks as this would allow anybody hitting "/file1" to get to the resource. You probably will want to check for the existence of the APM session before allowing this iRule to move to the redirect part.

    when HTTP_REQUEST {
    
    if { [HTTP::uri] equals "/file1" } then {
    
      set my_http_uri [HTTP::uri]
      log local0. "HTTP_URI = $my_http_uri"
    
      set expiry 30
      set secret "SuP3rS3cR3tK3y"
      set url_root "http://my.cdn.com"
      set resource "/test/info.pdf"
    
      timestamp = epoch time + expiry
    
      set now [clock seconds]
      set timestamp [expr {$now + $expiry}]
      log local0. "TIMESTAMP = $timestamp"
    
       salt = key . path ?e= timestamp
      set salt "$secret$resource?e=$timestamp"
      log local0. "SALT = $salt"
    
      hash = md5(salt)
      binary scan [md5 $salt] H* hash
      log local0. "HASH = $hash"
    
      url = url_root . path ?e= timestamp &h= hash
      set url "$url_root$resource?e=$timestamp&h=$hash"
      log local0. "URL = $url"
    
    }
    
    HTTP::redirect $url
    
    }
    

    Please let me know if this helps your solution.

    Seth