PATH:
home
/
letacommog
/
letaweb
/
admin
/
classes
/
components
<?php class urlComponent extends CApplicationComponent { public $root_host = 'localhost'; public $root_path = 'localhost'; public static function isValidDomain($domain_name) { return (preg_match("/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i", $domain_name) //valid chars check && preg_match('/^.{1,253}$/', $domain_name) //overall length check && preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $domain_name)); //length of each label } public static function checkDomain($name) { return strpos($name, '.') !== false; } public function get_current_dir($include_domain = true, $include_protocol = true) { $current_dir = getcwd(); $current_dir = str_replace('\\', '/', $current_dir); $current_dir = str_replace($_SERVER['DOCUMENT_ROOT'], '', $current_dir); $rs = ''; if ($include_protocol) { $rs .= 'http://'; } if ($include_domain) { $rs .= $this->root_host; } $rs .= '/'.$current_dir; return $rs; } public function get_base_absolute_path() { return Yii::getPathofAlias('application_site'); } public function get_session_path() { return $this->get_base_absolute_path(); } public function full_url($include_request = true, $include_domain = true, $include_protocol = true, $include_port = true) { $s = empty($_SERVER['HTTPS']) ? '' : ($_SERVER['HTTPS'] == 'on') ? 's' : ''; $sp = strtolower($_SERVER['SERVER_PROTOCOL']); $sn = $_SERVER['SERVER_NAME']; $sn = str_replace('www.', '', $sn); $protocol = substr($sp, 0, strpos($sp, '/')).$s; $port = ($_SERVER['SERVER_PORT'] == '80') ? '' : (':'.$_SERVER['SERVER_PORT']); $result = ''; if ($include_protocol) { $result = $protocol.'://'; } if ($include_domain) { $result .= $sn; } if ($include_domain) { $result .= $port; } if ($include_request) { $result .= $_SERVER['REQUEST_URI']; } return $result; } public function get_css_path() { $host = $_SERVER['HTTP_HOST']; if ($host == $this->root_host) { return Yii::app()->basedUrl; } return $this->full_url(false); } public function getDomain() { return $_SERVER['HTTP_HOST']; } public function getWebsiteURL() { $host = $_SERVER['HTTP_HOST']; if ($host == $this->root_host) { return $this->get_absolute_css_path(); } return $this->full_url(false); } public function getCookiePath() { $host = $_SERVER['HTTP_HOST']; if ($host == $this->root_host) { return $this->get_current_dir(false, false); } return $this->full_url(false, false, false, false); } public function get_script_path() { return Yii::app()->getBaseUrl(true); } public function get_absolute_css_path() { $website_name = Yii::app()->params['website_name']; $website_type = Yii::app()->params['website_type']; $path = Yii::getPathOfAlias('application_site'); $document_root = Yii::getPathOfAlias('application_root'); $path = str_replace($document_root, '', $path); $path = str_replace('\\', '/', $path); $path = Yii::app()->getBaseUrl(true).'/'.urldecode($path); return $path; } public function get_absolute_css_path2() { $context = Yii::app()->context; if ($context->website_name == $context->website_base_name) { $path = $this->get_base_dir(); } else { $path = $this->full_url(false); } return $path; } public function get_image_path($src) { if (strpos($src, 'http://') === false) { return $this->get_script_path().$src; } return $src; } public function get_module_url($module, $header = 1, $full_path = 0) { $src = 'module.php?name='.$module; if ($header === 0) { $src .= '&header=0'; } if ($full_path === 1) { $src = $this->get_absolute_css_path().'/'.$src; } return htmlentities($src); } public function createAdminURL($action = '', $parameters = '') { $page = 'admin.php/'.$action; $url = $page; $pstring = ''; if (is_array($parameters)) { foreach ($parameters as $name => $value) { if (is_array($value)) { foreach ($value as $vs) { $pstring .= '&'.$name.'='.urlencode($vs); } } else { $pstring .= '&'.$name.'='.urlencode($value); } } if (strlen($pstring) > 0) { $pstring = substr($pstring, 1); } } if (strlen($pstring) > 0) { $url .= '?'.$pstring; } $host_info = Yii::app()->request->getHostInfo(); $relative_url = Yii::app()->request->getBaseUrl().'/'.$url; $relative_url = ltrim($relative_url, '/'); return $host_info.'/'.$relative_url; } public function createPageURL($page = '', $parameters = array(), $absolute= false) { if($absolute) return Yii::app()->createAbsoluteUrl($page,$parameters ); return Yii::app()->urlManager->createUrl($page,$parameters ); if ($page === false) { $page = ''; } if (!is_array($parameters)) { $relative_url = Yii::app()->urlManager->createUrl($page); } else { $relative_url = Yii::app()->urlManager->createUrl($page, $parameters); } $host_info = Yii::app()->request->getHostInfo(); $relative_url = ltrim($relative_url, '/'); echo Yii::app()->request->getHostInfo(); echo $host_info.'/'.$relative_url; return $host_info.'/'.$relative_url; } public function redirectPage($page, $parameters=array()) { self::redirect(self::createPageURL($page, $parameters)); } public function redirect($url) { Yii::app()->request->redirect($url); } public function getMainSiteUrl($https = false) { $url = (isset(Yii::app()->mainSiteConfig['mainSiteUrl']) ? Yii::app()->mainSiteConfig['mainSiteUrl'] : $_SERVER['HTTP_HOST']); $url = preg_replace('#^https?://#', '', $url); return ($https ? 'https://'.$url : 'http://'.$url); } }
[+]
..
[-] colorComponent.php
[edit]
[-] authorizationComponent.php
[edit]
[-] hostingComponent.php
[edit]
[-] configComponent.php
[edit]
[-] siteComponent.php
[edit]
[-] urlComponent.php
[edit]
[-] paymentComponent.php
[edit]
[-] authManager.php
[edit]
[-] guestComponent.php
[edit]
[-] cmsComponent.php
[edit]
[-] languageComponent.php
[edit]
[-] contextComponent.php
[edit]
[-] cartComponent.php
[edit]
[-] customerComponent.php
[edit]