Continued...
/***************************************
** Function for parsing a Mysql result
** set.
***************************************/
function parse_sql($file_id, $result_name){
global $$result_name;
$loop_code = '';
$start_pos = strpos(strtolower($this->files[$file_id]), '<loop name="'.$result_name.'">') + strlen('<loop name="'.$result_name.'">');
$end_pos = strpos(strtolower($this->files[$file_id]), '</loop name="'.$result_name.'">');
$loop_code = substr($this->files[$file_id], $start_pos, $end_pos-$start_pos);
$start_tag = substr($this->files[$file_id], strpos(strtolower($this->files[$file_id]), '<loop name="'.$result_name.'">'),strlen('<loop name="'.$result_name.'">'));
$end_tag = substr($this->files[$file_id], strpos(strtolower($this->files[$file_id]), '</loop name="'.$result_name.'">'),strlen('</loop name="'.$result_name.'">'));
if($loop_code != ''){
$new_code = '';
$field_names = array();
for($i=0; $i<mysql_num_fields($$result_name); $i++) $field_names[] = mysql_field_name($$result_name,$i);
while($row_data = mysql_fetch_array($$result_name, MYSQL_ASSOC)){
$temp_code = $loop_code;
for($i=0; $i<count($field_names); $i++){
$temp_code = str_replace($this->start.$field_names[$i].$this->end, $row_data[$field_names[$i]], $temp_code);
}
$new_code.= $temp_code;
}
$this->files[$file_id] = str_replace($start_tag.$loop_code.$end_tag, $new_code, $this->files[$file_id]);
}
}
/***************************************
** Function for parsing a Postgres result
** set.
***************************************/
function parse_pgsql($file_id, $result_name){
global $$result_name;
$loop_code = '';
$start_pos = strpos(strtolower($this->files[$file_id]), '<loop name="'.$result_name.'">') + strlen('<loop name="'.$result_name.'">');
$end_pos = strpos(strtolower($this->files[$file_id]), '</loop name="'.$result_name.'">');
$loop_code = substr($this->files[$file_id], $start_pos, $end_pos-$start_pos);
$start_tag = substr($this->files[$file_id], strpos(strtolower($this->files[$file_id]), '<loop name="'.$result_name.'">'),strlen('<loop name="'.$result_name.'">'));
$end_tag = substr($this->files[$file_id], strpos(strtolower($this->files[$file_id]), '</loop name="'.$result_name.'">'),strlen('</loop name="'.$result_name.'">'));
if($loop_code != ''){
$new_code = '';
$field_names = array();
for($i=0; $i<pg_numfields($$result_name); $i++) $field_names[] = pg_fieldname($$result_name,$i);
for($i=0; $i<pg_numrows($$result_name) AND $row_data = pg_fetch_array($$result_name, $i); $i++){
$temp_code = $loop_code;
for($j=0; $j<count($field_names); $j++){
$temp_code = str_replace($this->start.$field_names[$j].$this->end, $row_data[$field_names[$j]], $temp_code);
}
$new_code.= $temp_code;
}
$this->files[$file_id] = str_replace($start_tag.$loop_code.$end_tag, $new_code, $this->files[$file_id]);
}
}
/***************************************
** Function looking for if blocks
** added by Stephan Lüderitz
***************************************/
function parse_if($file_id, $array_name){
$var_names = explode(',', $array_name);
for($i=0; $i<count($var_names); $i++){
$if_code = '';
$start_pos = strpos(strtolower($this->files[$file_id]), '<if name="'.strtolower($var_names[$i]).'">') + strlen('<if name="'.strtolower($var_names[$i]).'">');
$end_pos = strpos(strtolower($this->files[$file_id]), '</if name="'.strtolower($var_names[$i]).'">');
$if_code = substr($this->files[$file_id], $start_pos, $end_pos-$start_pos);
$start_tag = substr($this->files[$file_id], strpos(strtolower($this->files[$file_id]), '<if name="'.strtolower($var_names[$i]).'">'),strlen('<if name="'.strtolower($var_names[$i]).'">'));
$end_tag = substr($this->files[$file_id], strpos(strtolower($this->files[$file_id]), '</if name="'.strtolower($var_names[$i]).'">'),strlen('</if name="'.strtolower($var_names[$i]).'">'));
$new_code = '';
if($if_code != ''){
global ${$var_names[$i]};
if(@${$var_names[$i]})
$new_code = $if_code;
$this->files[$file_id] = str_replace($start_tag.$if_code.$end_tag, $new_code, $this->files[$file_id]);
}
}
}
/***************************************
** Function for printing the resulting
** file(s).
***************************************/
function print_file($file_id){
if(is_long(strpos($file_id, ',')) == TRUE){
$file_id = explode(',', $file_id);
for(reset($file_id); $current = current($file_id); next($file_id)) echo $this->files[trim($current)];
}else{
echo $this->files[$file_id];
}
}
/***************************************
** Function for returning the resulting
** file(s).
***************************************/
function return_file($file_id){
$ret = '';
if(is_long(strpos($file_id, ',')) == TRUE){
$file_id = explode(',', $file_id);
for(reset($file_id); $current = current($file_id); next($file_id)) $ret .= $this->files[trim($current)];
}else{
$ret .= $this->files[$file_id];
}
return $ret;
}
/***************************************
** Parses and then immediately prints
** the file. This function added by
** Bruce Christensen.
***************************************/
function pprint($file_id, $replacements = ''){
$this->register($file_id, $replacements);
$this->parse($file_id);
$this->print_file($file_id);
}
/***************************************
** Parses and then immediately returns
** the file's contents. Function added
** by Bruce Christensen.
***************************************/
function pget($file_id, $replacements = ''){
$this->register($file_id, $replacements);
$this->parse($file_id);
return $this->return_file($file_id);
}
/***************************************
** Loads a file, parses it, and prints it.
** This function added by Bruce Christensen.
***************************************/
function pprint_file($filename, $replacements = ''){
for($file_id=1; isset($this->files[$file_id]); $file_id++);
$this->load_file($file_id, $filename);
$this->pprint($file_id, $replacements);
unset($this->files[$file_id]);
}
/***************************************
** Loads, parses and then immediately
** returns the file's contents.
** Function added by Bruce Christensen.
***************************************/
function pget_file($filename, $replacements = ''){
for($file_id=1; isset($this->files[$file_id]); $file_id++);
$this->load_file($file_id, $filename);
return $this->pget($file_id, $replacements);
}
} // End of class
?>
Here is a very simple template (very little (like no, duh!) functionality except this offending nav bar
I beg sombody to tell me why it doesn't work
<table width="100%" border="5" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><INCLUDE FILENAME="list.php">
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
oh and finally list,
<?php
$dir = "../bunniesnew/";
if ($url = opendir($dir)) {
while (false !== (
$file = readdir($url))) {
$both = $dir.$file;
$link = "<a href=\"$both\">$file</a>";
echo $link,"<br>";
}
closedir($url);
}
?>
I'm gunna give up on the dynamic nav bar theory, but if any one can see, and tell me where this goes astray I'll be, shocked...😉 very happy and (probably be to over the the moon...)
Thanks