예제 #1
0
 /**
  * Get the value of a header.
  *
  * @param   string  $name  The name of a header
  * @return  string  The value of the header. If it does not exist, returns `null'.
  * @access  public
  */
 function head($name)
 {
     ESTRAIERPURE_DEBUG && EstraierPure_Utility::check_types(array($name, 'string'));
     return isset($this->heads[$name]) ? $this->heads[$name] : null;
 }
예제 #2
0
파일: search.php 프로젝트: joeymetal/v1
// get the result of search
$nres = &$node->search($cond, 0);
if ($nres) {
    // for each document in the result
    for ($i = 0; $i < $nres->doc_num(); $i++) {
        // get a result document object
        $rdoc = &$nres->get_doc($i);
        // display attributes
        if (($value = $rdoc->attr('@uri')) !== null) {
            fputs(STDOUT, sprintf("URI: %s\n", $value));
        }
        if (($value = $rdoc->attr('@title')) !== null) {
            fputs(STDOUT, sprintf("Title: %s\n", $value));
        }
        // display the snippet text
        fputs(STDOUT, sprintf("%s", $rdoc->snippet()));
    }
    if ($i == 0) {
        fputs(STDERR, "not found.\n");
    }
    // debug output
    //var_dump($i, $j, $nres->doc_num());
} else {
    fputs(STDERR, sprintf("error: %d\n", $node->status()));
    $stack = &EstraierPure_Utility::errorstack();
    if ($stack->hasErrors()) {
        fputs(STDERR, print_r($stack->getErrors(), true));
    }
}
?>
예제 #3
0
 /**
  * Set information of the node.
  *
  * @return  void
  * @access  private
  */
 function set_info()
 {
     $this->status = -1;
     if (!$this->url) {
         return;
     }
     $turl = $this->url . '/inform';
     $reqheads = array();
     if ($this->auth) {
         $reqheads['authorization'] = 'Basic ' . base64_encode($this->auth);
     }
     $res =& EstraierPure_Utility::shuttle_url($turl, $this->pxhost, $this->pxport, $this->timeout, $reqheads);
     if (!$res) {
         return;
     }
     $this->status = $res->status();
     if ($res->is_error()) {
         return;
     }
     $lines = explode("\n", $res->body());
     if (count($lines) == 0) {
         return;
     }
     $elems = explode("\t", $lines[0]);
     if (count($elems) != 5) {
         return;
     }
     $this->name = $elems[0];
     $this->label = $elems[1];
     $this->dnum = intval($elems[2]);
     $this->wnum = intval($elems[3]);
     $this->size = floatval($elems[4]);
     $llen = count($lines);
     if ($llen < 2) {
         return;
     }
     $lnum = 1;
     if ($lnum < $llen && strlen($lines[$lnum]) < 1) {
         $lnum++;
     }
     $this->admins = array();
     while ($lnum < $llen) {
         $line = $lines[$lnum];
         if (strlen($line) < 1) {
             break;
         }
         $this->admins[] = $line;
         $lnum++;
     }
     if ($lnum < $llen && strlen($lines[$lnum]) < 1) {
         $lnum++;
     }
     $this->users = array();
     while ($lnum < $llen) {
         $line = $lines[$lnum];
         if (strlen($line) < 1) {
             break;
         }
         $this->users[] = $line;
         $lnum++;
     }
     if ($lnum < $llen && strlen($lines[$lnum]) < 1) {
         $lnum++;
     }
     $this->links = array();
     while ($lnum < $llen) {
         $line = $lines[$lnum];
         if (strlen($line) < 1) {
             break;
         }
         $links = explode($line);
         if (count($links) == 3) {
             $this->links[] = $links;
         }
         $lnum++;
     }
 }
예제 #4
0
파일: register.php5 프로젝트: joeymetal/v1
//define('ESTRAIERPURE_USE_HTTP_STREAM', 1);
error_reporting(E_ALL & ~E_STRICT);
require_once 'estraierpure.php5';

// create and configure the node connecton object
$node = new EstraierPure_Node;
$node->set_url('http://*****:*****@uri', 'http://estraier.example.com/example.txt');
$doc->add_attr('@title', 'Bridge Over The Troubled Water');

// add the body text to the document object
$doc->add_text('Like a bridge over the troubled water,');
$doc->add_text('I will ease your mind.');

// register the document object to the node
if (!$node->put_doc($doc)) {
    fprintf(STDERR, "error: %d\n", $node->status());
    if (EstraierPure_Utility::errorstack()->hasErrors()) {
        fputs(STDERR, print_r(EstraierPure_Utility::errorstack()->getErrors(), true));
    }
} else {
    fputs(STDOUT, "success.\n");
}
?>