service = $service; $this->resultsperpage = $resultsperpage; $this->totalresults = $this->firstresult = $this->lastresult = 0; } /* ** Perform a query for $q starting at $rank. Return true on success, ** false on error (no results is not an error) */ function query($q, $rank=0) { global $it_text; if (is_object($it_text)) $lang = "&lang=" . $it_text->get_language(); $url = $this->service . "?q=" . urlencode($q) . "$lang&rank=$rank&n=" . $this->resultsperpage; /* debug("it_darwin::query(\"$url\",$rank)"); */ if ($this->result = file($url)) { $this->totalresults = trim($this->result[2]); $this->firstresult = trim($this->result[3]); $this->lastresult = trim($this->result[4]); $this->resptr = $this->firstresult; return 1; } return 0; } /* Fetch a result as an array "url", "title", "description", "size", "date" */ function fetch_array($number="XX") { /* debug("fetch_array($number), resptr==$this->resptr"); */ if ($number != "XX") $this->resptr = $number; if (($this->resptr >= $this->firstresult) && ($this->resptr <= $this->lastresult)) { $n = 5+($this->resptr-$this->firstresult)*5; /* start of result record */ $this->resptr+=1; /* Spinn ich?? ++ geht nicht !! */ return array("url" => trim($this->result[$n]), "title" => trim($this->result[$n+1]), "description" => trim($this->result[$n+2]), "size" => trim($this->result[$n+3])*1024, "date" => trim($this->result[$n+4])); } else return 0; /* Out of bounds */ } } /* End class it_darwin_query */ ?>