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

class Controller{   
   
    protected $model;
	protected $template;
	protected $getcontroller;
	protected $sfile;
	protected $fh;
	protected $owner;		
	protected $data;
	protected $content;
    
	
		
	public function __construct($model){
		  						
	    $this->$model = new $model;
		$this->template = new Template($file_name, $variables_array);
		$this->menu = new Menu();		
			
						    
	}
	
				
	
    public function requireSession($owner){
	
	    $this->owner = $owner;
		if(!isset($_SESSION[$owner])){
		    header("Location: index.php");
			exit();
		}		
	
	}
	
	
	
	public function noRequireSession($owner){
	
	    $this->owner = $owner;
		if(isset($_SESSION[$owner])){
		    header("Location: index.php");
			exit();
		}		
	
	}
	
	
	
	public function nl2brFormatted($content){
	
	  $this->content = $content;
  
      $this->content = preg_replace("/(\n)+/","\n",$this->content);	
	  $this->content = preg_replace("/<(.*?)>\n/","<$1>",$this->content);
	  $this->content = preg_replace("/<\/(.*?)>\n/","</$1>",$this->content);		  
	  $this->content =  nl2br($this->content);
	  $this->content = preg_replace("/(<br \/>)+/","<br />",$this->content);	
	  $this->content = preg_replace("/<(.*?)><br \/>/","<$1>",$this->content);
	  $this->content = preg_replace("/<\/(.*?)><br \/>/","</$1>",$this->content);
	  
	  return $this->content;
  
  }
  
  
  
     public function filterGet($data){
	 
	     $this->data = $data;
	     strip_tags($this->data);
		 return $this->data;
	 
	 }
	 
	 
	 
	 public function filterPost($data){
	 
	     $this->data = $data;
	     strip_tags($this->data);
		 return $this->data;
	 
	 }
	
	
	
	
	public function filterText($data){
	    
	  $this->data = $data;
		
	  if(DEMO_MODE === true){	
		
		include(ROOT_DIR."lib/htmlpurifier/library/HTMLPurifier.auto.php"); 
		
	    $config = HTMLPurifier_Config::createDefault();
        $config->set('HTML.Allowed', 'p[style],b,i,em,span[style],strong,address,pre,h1,h2,h3,h4,h5,h6,ul,li,ol,br');
		$config->set('CSS.AllowedProperties', array('text-decoration','text-align','font-family','font-size','color', 'background-color'));
		$config->set('HTML.Trusted', true);		        		       					
        $config->set('AutoFormat.AutoParagraph', true); 
        $config->set('Cache.DefinitionImpl', null); 
		$def = $config->getHTMLDefinition(true);       

        $purifier = new HTMLPurifier($config);
		$clean_html = $purifier->purify( $data );
		
      }else{
		
		$clean_html = $data;
		
	  }
		
		return $clean_html;
		
	
	}

	

}

?>
Return current item: EasyMyNews - News publishing script