We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1512
    • 57 Posts
    Hi there,

    We have a website and we have several links OUT to other websites. We want a simple snippet that can take the referring URL and display it in an iframe.

    E.g. We have a page: /subdir/page.html and it has a link to www.somedomain.com

    I have created a page called /url.html that contains my iframe code (with a menu bar across the top so ppl still know they are on my site) and i want www.somedomain.com to load. Now we have ALOT of pages that link out to www.somedomain.com or www.someotherdomain.com so i want to basically be able to change the url that ppl click on to url.html?www.somedomain.com

    i hope ive explained myself well enough. For any php guru, this should be a real quick job. We also have alot of potential for on-going work.

    We have a budget for this, so please name your price. And as always, the work will be donated back to the community!

    Regards
    André
      • 1122
      • 209 Posts
      Both "PHP guru" and "budget" are far too much for this task which requires exactly one line of code:
      the snippet "load_iframe":
      <?php return isset($_GET['url']) && $_GET['url'] ? $_GET['url'] : ''; ?>
      
      on /url.html page:
      <iframe src="[[load_iframe]]" ... ></iframe>
      
      change outside urls to:
      /url.html?url=http://www.somedomain.com
      
        • 1512
        • 57 Posts
        Alik, thank you so much! It works perfectly!

        Best regards
        André
          • 1122
          • 209 Posts
          Though it is working, you need to do further improvements to this solution, because it allows for loading into your site the content you wouldn’t be delighted with. Consider that someone will link your site with this:
          http://yourdomain.com/url.html?url=http://somenastysite.xxx....

          By sending my one-line snippet I only wanted to say that your issue is easy to realize/master, but you still need to take care of details. The snippet might/should be remastered as:
          <?php
          if (isset($_GET['url']) && $_GET['url']) {
            // here do the careful check of the url
            // ...
            // ...
            if ("url-is-allowed-or-within-predefined-set") {
              // send it to the iframe
              return $_GET['url'];
            }
          }
          // url either not set or not allowed -> block it
          return '';
          ?>
          

          Good luck with this!