url(s)


  
      function set_url(url)
      {
           this->url = this->decode_url(url);
  
           if (strpos(this->url, '://') === false)
           {
               this->url = '' . this->url;
           }
  
          url_segments = @parse_url(this->url);
          
          if (!empty(url_segments))
          {
              url_segments['port']     = isset(url_segments['port']) ? url_segments['port'] : 80;
              url_segments['path']     = isset(url_segments['path']) ? url_segments['path'] : '/';
              url_segments['dir']      = substr(url_segments['path'], 0, strrpos(url_segments['path'], '/'));
              url_segments['base']     = url_segments['scheme'] . '://' . url_segments['host'] . url_segments['dir'];
              url_segments['prev_dir'] = url_segments['path'] != '/' ? substr(url_segments['base'], 0, strrpos(url_segments['base'], '/')+1) : url_segments['base'] . '/';
  
              this->url_segments = url_segments;
  
              /*
                   URL: username:password@www.example.com:80/dir/dir/page.php?foo=bar&foo2=bar2#bookmark
                   scheme   // http
                   host     // www.example.com
                   port     // 80
                   user     // username
                   pass     // password
                   path     // /dir/dir/page.php
                   query    // ? 'foo=bar&foo2=bar2'
                   fragment // # 'bookmark'
  
                   dir      // /dir/dir
                   base     // www.example.com/dir/dir
                   prev_dir // www.example.com/dir/
               */
  
               if (!empty(this->allowed_hosts) && !in_array(this->url_segments['host'], this->allowed_hosts))
               {
                   this->trigger_error('You are only allowed to browse these websites: ' . implode(', ', this->allowed_hosts));
               }
           }
           else
           {
               this->trigger_error('Please supply a valid URL');
           }
      }