hi,
I need some help with this class I can't figure out why its not working
<?php
/*
Template Class
File: template.php
*/
/* Begin Template Class */
class template {
var $temp;
var $size;
var $mode;
var $directory;
function template() {
$this->directory = "/home/user/public_html/templates";
}
function topen($filename, $blocksize, $read) {
$this->temp = $filename;
$this->size = $blocksize;
$this->mode = $read;
if($fp = fopen("$directory/$filename", "$read")) {
$data = '';
while(!feof($fp)) {
$data .= fread($fp, "$blocksize");
}
}else{
print "Error: Could not open template from $directory/$filename";
}
print $data;
fclose($fp);
}
}
?>
<?php
/*
Display Template(s)
File: test.php
*/
/* Include Template Class */
include('./template.php');
/* Call Template Class */
$template = new template;
/* Display Template */
$template->topen("main.txt",'1572864','r');
?>
I'll explain what its suppost to do incase I am no where close to how its suppost to be. Its suppost to open the file in this case main.txt located in the templates directory and read the code in blocks of 1572864 Bytes (or 1.5MB). And output the resulting HTML.
[EDIT]
It currently doesn't seem to follow the $directory variable it just trys to read /main.txt if I hard code the path in there /home/user/templates it works. Can somone help me fix this?
Also how would I preform more then one eregi_replace() on the same bit of information and have it print the results only 1 time?
when i do
echo eregi_replace("{news}","$news", "$data");
echo eregi_replace("{who_online}","$whois","$data");
it prints the page out twice.
Thanks for your help,
-AB