Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php coding assistance with templete.php

    I get this error:

    Warning: feof(): supplied argument is not a valid stream resource in /home/herbals/public_html/community/membersonly/template.php on line 48

    Warning: fgets(): supplied argument is not a valid stream resource in /home/herbals/public_html/community/membersonly/template.php on line 49

    Here is my code:

    <?php
    /*
    class: template
    purpose: template engine
    */
    class template extends membersonly{

    /*
    function: define_file
    purpose: defines template file
    */
    function define_file($file){
    $this->template_file=$file;
    $this->template_regioncount=-1;
    }

    /*
    function: add_region
    purpose: adds template dynamic region
    */
    function add_region($region,$value){
    $this->template_regioncount++;
    $this->template_regions[$this->template_regioncount]=$region;
    $this->template_regionvalues[$this->template_regioncount]=$value;
    }

    /*
    function: debug
    purpose: set debugging to true
    */
    function debug(){
    $this->template_debug="true";
    }

    /*
    function: make_template
    purpose: make and display template
    */
    function make_template() {
    $fp = @fopen($this->membersonly_path.$this->template_dir.$this->template_file,"r");
    $regioncount=count($this->template_regions);
    for ($i=0; $i<$regioncount; $i++){
    if ($this->template_regions[$i]=="headers"){
    $page=$this->template_regionvalues[$i];
    }
    }
    $page.="<!--This community runs on Herbal Sacred Ground Web Hosting ".$this->membersonly_version."\nhttp://herbalsacredground.com-->\n";
    while (!feof($fp)){
    $line = fgets($fp);
    $line = stripslashes($line);
    $line = preg_replace("/href=\"..\//","href=\"".$this->membersonly_webpath,$line);
    $line = preg_replace("/src=\"..\//","src=\"".$this->membersonly_webpath,$line);
    for ($i=0; $i<$regioncount; $i++){
    $line = preg_replace("/{".$this->template_regions[$i]."}/",$this->template_regionvalues[$i],$line);
    }
    $page.=$line;
    }
    $tempfile=$this->membersonly_path.$this->template_tempdir.rand(111111111,999999999).".php";
    $temp = @fopen($tempfile,"w+");
    fwrite($temp, $page);
    fclose($temp);
    include ($tempfile);
    if ($this->template_debug=="false"){
    unlink($tempfile);
    }
    }

    }
    ?>

  • #2
    Senior Coder
    Join Date
    Apr 2005
    Location
    Colorado, United States
    Posts
    1,208
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It looks like the file doesn't exist to me, or you don't have permissions to modify it.
    "$question = ( to() ) ? be() : ~be();"

  • #3
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What do you mean?

  • #4
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    Putting @ in front of functions before you know they work is really silly.
    Try fopen(...) or die("COuldn't open file on line xxx");
    instead, and it might be helpful

  • #5
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Also, please wrap your code in [PHP] tags as described here.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •