Location: PHPKode > projects > EasyMyNews - News publishing script > easymynews/lib/model.class.php
<?php 
class Model{


  
    protected $sfile;
	protected $content;		
	protected $fh;
	
	
	public function readFile($sfile){
	
	   $this->sfile = $sfile;	  
    
       $this->content = file_get_contents($this->sfile);			
	   	   
	   return $this->content;
    
   }
   
   
   
   public function writeFile($sfile, $content){
   
       $this->sfile   = $sfile;	      
       $this->content = $content;
       
	   if(is_writable($sfile)){
           $this->fh   = fopen($this->sfile, 'w') or die("can't open ".$this->sfile." file");
	       flock($this->fh, LOCK_EX);
	       fwrite($this->fh,trim($this->content));
	       flock($this->fh, LOCK_UN);
	       fclose($this->fh);
	   }else{	   	   
	       exit("The file is not writable!");
	   }
   
   }
   
   
  
   
  
  
  

}
?>
Return current item: EasyMyNews - News publishing script