WordPress.org

Ready to get started?Download WordPress

Forums

PHP in post (6 posts)

  1. larbear
    Member
    Posted 3 years ago #

    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

    <?php
    // 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

  2. Chris McCoy
    Member
    Posted 3 years ago #

    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.

    <?php
    
    $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.addParam("allowfullscreen","true");
      so.addParam("allowscriptaccess","always");
      so.addParam("wmode","opaque");
      so.addVariable("autostart","true");
      so.addVariable("file","<?php echo $url;?>");
      so.write("flashcontent");
    </script>
  3. webweb
    Member
    Posted 3 years ago #

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

  4. webweb
    Member
    Posted 3 years ago #

    Nevermind , sorted !

  5. Chris McCoy
    Member
    Posted 3 years ago #

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

  6. webweb
    Member
    Posted 3 years ago #

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

    Voila !

    Thanks for Your reply Chris

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags