Login   Register  
PHP Classes
elePHPant
Icontem

File: RemoteContent.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Eugene Panin  >  Remote Content retriever  >  RemoteContent.php  >  Download  
File: RemoteContent.php
Role: ???
Content type: text/plain
Description: Remote Content class
Class: Remote Content retriever
Author: By
Last change:
Date: 13 years ago
Size: 1,879 bytes
 

Contents

Class file image Download
<?
/**
 ** Remote content retrieves remote URL or local file
 ** and sets it to the variable.
 ** Usability of this class is under GPL.
 ** @extendsPath SimpleObject.php
 ** @author Eugene Panin, var@express.ru
 **/

class RemoteContent extends SimpleObject {
        var $url        = '';
        var $data       = '';

        /**
         ** Creates a RemoteContent object.
         ** Class constructor.
         ** @param URL The URL to retrieve data.
         **/
        function RemoteContent($url='') {
                $this->setError('');
                $this->_retrieve($url);
        }

        /**
         ** @returns string Returns a string reflecting the remote data.
         ** @scope public
         **/
        function getData() {
                if (!$this->data) {
                        $this->_retrieve($this->url);
                }
                return $this->data;
        }

        /**
         ** Sets a new URL then retrieves data from one.
         ** @param URL The new URL.
         ** @returns void
         ** @scope public
         **/
        function setURL($url='') {
                if ($url) {
                        $this->url = $url;
                        $this->data = '';
                }
        }
        /**
         ** Retrieves remote file.
         ** @param URL The URL to retrieve data.
         ** @returns void
         ** @scope private
         **/
        function _retrieve($url='') {
                $this->setError('');
                if ($url) {
                        $this->data = join('',file($url));
                        $this->url = $url;
                }
                else {
                        $this->setError("RemoteContent._retrieve error: empty URL");
                        return;
                }
        }

}
?>