0 && preg_match("/^ *$/", $lines[0]))
array_shift($lines);
}
function trimEmpties(&$lines)
{
while (($len = count($lines)) > 0 && preg_match("/^ *$/", $lines[$len-1]))
array_pop($lines);
}
function &fixUpTerms($terms)
{
if (!is_array($terms))
$terms = array($terms);
$terms2 = array();
foreach ($terms as $i => $term)
{
$term = preg_replace('/\//', '\/', $term);
$terms2[] = '/' . $term . '/';
}
return $terms2;
}
function &highlightterms($terms, $text)
{
$high = array(
'$0',
'$0',
'$0',
'$0',
'$0',
'$0',
);
// print_r($terms);
// print "
";
// print_r($high);
// print "
$text
\n";
$terms = fixUpTerms($terms);
$x = preg_replace($terms, $high, $text);
// print "$x
\n";
// print "
";
return $x;
}
class Criteria
{
var $name;
var $textname;
var $book;
var $dir;
var $webtrust;
var $requirement;
var $comments;
var $verified;
var $mark_regexp;
function Criteria($name, $loc = '')
{
if ($e = isBadName($name))
exit("not a Criteria ($e): $name");
$this->name = $name;
$book = substr($name, 0, 1);
$this->dir = "{$book}/{$this->name}";
$this->webtrust = $this->requirement = $this->comments = $this->verified =
false;
$mark_regexp = false;
}
function criteriaFile() { return $this->dir . "/" . $this->name . ".html"; }
function criteriaVerified() { return $this->dir . "/verified.html"; }
function criteriaComments() { return $this->dir . "/comments.html"; }
function &stripTable(&$data)
{
$lines = explode("\n", $data);
if (preg_match('/^ */', $line))
array_pop($lines);
return $lines;
}
function &getNextTD(&$lines)
{
$e1 = " ";
$e2 = " ";
$block = array();
skipEmpties($lines);
$line = $lines[0];
if (!preg_match('/^ */', $line))
return $e1 . "";
$line = array_shift($lines);
if (preg_match('/^ * | (.*)<\/TD> *$/', $line, $matches))
{
return $matches[1];
}
$inblock = true;
while ($inblock && count($lines) > 0)
{
$line = array_shift($lines);
if (preg_match('/^ *<\/TD> *$/', $line))
$inblock = false;
else
$block[] = $line;
}
if ($inblock)
return $e2;
$newdata = join("\n", $block);
return $newdata;
}
function initCriteria()
{
$data = read_content_of_file($this->criteriaFile());
if (!$data)
{
$this->textname = " {$this->name} ";
$this->webtrust = " ";
$this->requirement = " file not found ";
return;
}
$lines = $this->stripTable($data);
$this->textname = $this->getNextTD($lines);
$this->webtrust = $this->getNextTD($lines);
$this->requirement = $this->getNextTD($lines);
}
function initStraight($name)
{
$data = read_content_of_file($name);
if (!$data)
{
$this->comments = "";
return;
}
$lines = $this->stripTable($data);
$new_data = join("\n", $lines);
return $new_data;
}
function initComments()
{
$this->comments = $this->initStraight($this->criteriaComments());
}
function initVerified()
{
$this->verified = $this->initStraight($this->criteriaVerified());
}
function getTextName()
{
if (!$this->textname)
$this->initCriteria();
return $this->textname;
}
function getWebTrust()
{
if (!$this->webtrust)
$this->initCriteria();
return $this->webtrust;
}
function getRequirement()
{
if (!$this->requirement)
$this->initCriteria();
return $this->requirement;
}
function getVerified()
{
if (!$this->verified)
$this->initVerified();
return $this->verified;
}
function getComments()
{
if (!$this->comments)
$this->initComments();
return $this->comments;
}
function _setup_mark_regexp()
{
if ($this->mark_regexp)
return ;
$this->mark_regexp = array();
$this->mark_regexp['req'] =
preg_replace('/ |