Support » Plugins » PHP in post

  • larbear


    Hi, I am trying to put a video in my blog posts but I want to use Mod-auth-token to prevent hotlinking and it requires that the page with the video has a piece of php code

    // Settings to generate the URI
    $secret = "secret string"        // Same as AuthTokenSecret
    $protectedPath = "/downloads/"         // Same as AuthTokenPrefix
    $ipLimitation = false;                 // Same as AuthTokenLimitByIp
    $hexTime = dechex(time());             // Time in Hexadecimal
    $fileName = "/file_to_protect.txt";    // The file to access
    // Let's generate the token depending if we set AuthTokenLimitByIp
    if ($ipLimitation) {
      $token = md5($secret . $fileName . $hexTime . $_SERVER['REMOTE_ADDR']);
    else {
      $token = md5($secret . $fileName. $hexTime);
    // We build the url
    $url = $protectedPath . $token. "/" . $hexTime . $fileName;
    echo $url;

    I have tried to use exec-php but it does not seem to work. Is there any other way I can put php code into the page, doesnt necessarily have to be in the post just on the page.
    Thank you

Viewing 5 replies - 1 through 5 (of 5 total)
  • I actually just setup mod_auth_token with videos.

    i dont know which video plugin you are using you might need to mod it to parse the url. but something like this.

    $secret = "secret";
    $path = "/downloads/";
    $htime = dechex(time());
    $fname = "/video.flv";
    $token = md5($secret . $fname. $htime);
    $url = $path . $token. "/" . $htime . $fname;
    <script type="text/javascript">
      var so = new SWFObject("player.swf","mpl","450","290","9");
      so.addVariable("file","<?php echo $url;?>");

    But what about more than one file ?
    I’m stucked on that thing.

    Nevermind , sorted !

    you could create a shortcode that passes the video file onto a variable, that way it will make it easier for you.

    I’ve had a $file variable in my script,
    and I passed it like
    $filename = basename($file) ;

    Voila !

    Thanks for Your reply Chris

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘PHP in post’ is closed to new replies.