A super easy PHP Framework for web development!
				https://github.com/exacti/phacil-framework
			
			
		
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							59 lines
						
					
					
						
							1.2 KiB
						
					
					
				
			
		
		
	
	
							59 lines
						
					
					
						
							1.2 KiB
						
					
					
				<?php
 | 
						|
class Url {
 | 
						|
	public $baseurl;
 | 
						|
	private $url;
 | 
						|
	private $ssl;
 | 
						|
    public $cdn = false;
 | 
						|
	private $hook = array();
 | 
						|
	
 | 
						|
	public function __construct($url, $ssl) {
 | 
						|
		$this->url = $url;
 | 
						|
		$this->ssl = $ssl;
 | 
						|
        if(defined('CDN')) {
 | 
						|
            $this->cdn = CDN;
 | 
						|
        } else {
 | 
						|
            $this->cdn = false;
 | 
						|
        }
 | 
						|
		
 | 
						|
		if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
 | 
						|
			$this->baseurl = $ssl;
 | 
						|
		} else {
 | 
						|
			$this->baseurl = $url;
 | 
						|
		}
 | 
						|
	}
 | 
						|
	
 | 
						|
	public function link($route, $args = '', $connection = 'NONSSL') {
 | 
						|
		if ($connection ==  'NONSSL') {
 | 
						|
			$url = $this->url;	
 | 
						|
		} else {
 | 
						|
			$url = $this->ssl;	
 | 
						|
		}
 | 
						|
		
 | 
						|
		$url .= 'index.php?route=' . $route;
 | 
						|
		
 | 
						|
		if ($args) {
 | 
						|
			if (is_array($args)) {
 | 
						|
				$url .= '&' . http_build_query($args);
 | 
						|
			} else {
 | 
						|
				//$url .= str_replace('&', '&', '&' . ltrim($args, '&'));
 | 
						|
				$url .= '&' . ltrim($args, '&');
 | 
						|
			}
 | 
						|
		}
 | 
						|
		
 | 
						|
		
 | 
						|
		return $this->rewrite($url);
 | 
						|
	}
 | 
						|
		
 | 
						|
	public function addRewrite($hook) {
 | 
						|
		$this->hook[] = $hook;
 | 
						|
	}
 | 
						|
 | 
						|
	public function rewrite($url) {
 | 
						|
		foreach ($this->hook as $hook) {
 | 
						|
			$url = $hook->rewrite($url);
 | 
						|
		}
 | 
						|
		
 | 
						|
		return $url;		
 | 
						|
	}
 | 
						|
}
 | 
						|
?>
 |