function FileReader($file = NULL) { $fileobj = NULL; if (!isset($file)) { return; } if (URL::validClass($file)) { $fileobj = $file; $path = $fileobj->toString(); } else { if (File::validClass($file)) { $fileobj = $file; $path = $fileobj->getFilePath(); } else { $str = StringBuffer::toStringBuffer($file); if ($str->startsWith('http://') || $str->startsWith('ftp://') || $str->startsWith('php://')) { $fileobj = new URL($str); $path = $fileobj->toString(); } else { $fileobj = new File($file); $path = $fileobj->getFilePath(); } } } if (isset($fileobj)) { $this->handle = @fopen($path, 'r'); if (isset($this->handle)) { $this->file = $fileobj; } } }
static function rewrite(Location $l) { $rv = Location::rewrite($l); $u = new URL($rv); $action = $u->query['action']; unSet($u->query['action']); $u->resource = $action; return str_replace('?', '/', $u->toString()); }
static function rewrite(Location $l) { $rv = Location::rewrite($l); $u = new URL($rv); list($path, $res) = explode('?', $rv); $res = base64_encode($res); $u->query = array(); $u->resource = ''; return $u->toString() . $res; }
/** * Tests whether two URLs are equal. * Two URLs are equal if they have all fields equal, possibly except for ref * * @param mixed $url the url to compare to * @return bool true if two locations are equal */ function equals($url) { if (! ( $url instanceof URL)) $url = new URL($url); return $url->isWellformed() && $this->isWellformed() && ($this->toString(false) === $url->toString(false)); }
public function isSealed(URL $url) { if ($this->sealBase->toString() == $url->toString()) { return true; } return false; }
/** @return string */ public function toString() { return $this->url ? $this->url->toString() : $this->path; }