RestrictedIP: How does this work?

Last post 11-06-2008 10:04 PM by BarryR. 21 replies.
Page 2 of 2 (22 items) < Previous 1 2
Sort Posts: Previous Next
  • 10-03-2008 10:28 AM In reply to

    Re: RestrictedIP: How does this work?

    Barry, now this I can understand.  I've saved the code below as "download.php" and put it in my root folder.  I've changed the paths to the Zend library and entered my credentials.  No errors are thrown, but I am redirected to my home page in the lightbox, not the html file I liked to as follows:


    <a rel="lightbox;width=680;height=545" href="download.php?path=/register/Register2.html">Click here</a>


    <?php

        session_start();
        if (!isset($_SESSION['userData'])) {
            header( 'Location: index.php');
        }

        require_once "libraries/Zend/Config.php";
        set_include_path(get_include_path() . PATH_SEPARATOR . $INCLUDEPATH);
        require_once $INCLUDEPATH . '/libraries/Zend/Service/Nirvanix.php';
       
        // Use Cache library to reduce the number of lookups needed to download.
        require_once $INCLUDEPATH . '/libraries/Zend/Cache.php';

        $frontendOptions = array(
           'lifetime' => 100, // 10 second cache
           'automatic_serialization' => true);
          
        $backendOptions = array(
            'cache_dir' => './cache/' // Directory where to put the cache files
        );
       
        // getting a Zend_Cache_Core object
        $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);

        // Strip path chars from cache key
        $reqpath = str_replace(array('.', '/', ':', '-', '_', '%', '='), '', base64_encode($_REQUEST['path']));
       
        // Lookup path in cache
        if(!$dlurl = base64_decode($cache->load($reqpath))) {
            //plug-in your credentials below. You can sign-up at HTTP://www.nirvanix.com
            $appkey = $_SESSION['userData']['12345678-6F62-FAKE-KEYS-5X849EB25XXXX];
            $username = $_SESSION['userData']['meABC'];
            $password = $_SESSION['userData']['mypassword123'];
            $auth = array('username' => $username,'password' => $password,'appKey'   => $appkey);
           ...
        }
    ?>

    I'm thinking there are paths to change in the html file made by Camtasia Studio that links to the .flv file.  Direct links to the .flv don't work either, just a lightbox of my home page.  Any idea what's happening?
  • 10-04-2008 4:04 PM In reply to

    • mmania
    • Top 10 Contributor
    • Joined on 01-20-2008
    • Netherlands
    • Posts 93

    Re: RestrictedIP: How does this work?

    Kevin,

     sorry if my reply did not sound right, it was really not my intention... I just wanted to give you an honest advice on how best to proceed based on what I could read on your posts...

     again apologies if it did not sound right...

     ciao

     Luca

     

     

    kwoolf:

     Hi Luca,

    I was expecting a bit more encouragement than that, but I have indeed found a developer.  The developer wants to know what I want, so in order to tell him what I want, I need to know how this works.  Like I've mentioned above, I have made progress, and if you've seen my site you'd probably say I'm a bit more capable than a simple CMS user (www.yoostudy.net).  So if my questions above can get answered, I most surely can accomplish what I need to get done.  Hope you can give more direction!

     
  • 10-05-2008 2:43 PM In reply to

    Re: RestrictedIP: How does this work?

     Hi Barry,

     I'm still playing with the code you gave here but it's not retrieving files.  What I'm getting is a redirect to my homepage.  Please check the post above.  I have done the following:

    • Inserted new include_path to php.ini file for latest Zend
    • Copied code above into a file "download.php" and saved in root directory
    • Inserted credentials into the "download.php" file (appKey, username, password)
    • Configured URL as instructed <a href="download.php?path=client_logos.swf">Download link</a>
    • Checked file is not shared on Nirvanix

    I've played around with the URLs and have intentionally misconfigured some and have received Nirvanix XML response errors, so I know I'm communicating.  What am I doing wrong?  Thanks!

  • 10-06-2008 6:51 PM In reply to

    • BarryR
    • Top 10 Contributor
    • Joined on 07-20-2007
    • San Diego
    • Posts 885

    Re: RestrictedIP: How does this work?

     

    kwoolf:
    <a href="download.php?path=client_logos.swf

    the link as you configured it means that client_logos.swf would exist in the root of the account you are logging in to.  This path= should point to the path on the Nirvanix account.  That should be the only issue, sharing or not sharing this method should work since it generates a URL to the file and does not use the shared concept.

     Regards,
          Barry R.

    IM Support (Feel free to add me)

    MSN: barryruffner@live.com
    Gmail: barryruffner@gmail.com
  • 10-07-2008 3:34 PM In reply to

    Re: RestrictedIP: How does this work?

     Hi Barry,

     The solution is not working.  In a pre-project meeting, I had my developer take a look and he told me that I don't want "expiring" URLs that your solution gives me.  He's wondering about best practices because, from what I'm gathering, there are many ways to do what I want.  The code you posted was checked, re-checked and checked again, but all I get is a redirect to my homepage. Hope you can go over it and see if there are any inadvertent errors or if you can think of anything else I could be missing.  I don't want to pay this guy until I'm sure I know this will work.  Thanks!

    Kevin

  • 10-15-2008 12:39 PM In reply to

    Re: RestrictedIP: How does this work?

     I got a reply from a programmer, but she isn't familiar with Nirvanix.  She gave the following suggestions, so could you please look it over and give feedback?  Thanks!

    Normal 0 0 2 false false false EN-US ZH-TW X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-font-kerning:1.0pt;}

    After observing "download.php", my opinions are as follows
             1.Check whether the SESSION Variable: userData exists
                   In your code

                                if (!isset($_SESSION['userData']))
                                {
                                        header( 'Location: index.php');
                                }
                   I guess there is a problem when setting the value of "userData" , so you always see the index.
                   Maybe you can print userData on the screen to see what it is and try to correct it.
                 
             2.Move the line: "session_start(); " to line2 ; (under "<?php")

             3.About some variables

                   $appkey = "C8BCF626-XXX-4D18-XXX-53849EB259F2";

                   $username = "myusername";
                   $password = "mypassword";
                   You have to save the value into variable rather than take them as array's index.

     
  • 11-06-2008 10:04 PM In reply to

    • BarryR
    • Top 10 Contributor
    • Joined on 07-20-2007
    • San Diego
    • Posts 885

    Re: RestrictedIP: How does this work?

     The userData variable is just an array with the appkey, username and password.  Feel free to modify the code to match your environment.  In the example I provided the session stores those variables but you can just as easily put the values in directly as you show in point #3.

     Regards,
        Barry R.

     

    IM Support (Feel free to add me)

    MSN: barryruffner@live.com
    Gmail: barryruffner@gmail.com
Page 2 of 2 (22 items) < Previous 1 2