/** * Make an internal link. * * @param string $sUrl Internal link. * @param array $aParams ARRAY of params to include in the link. * @param bool $bFullPath Not using this argument any longer. * @return string Full URL. */ public function makeUrl($sUrl, $aParams = array(), $bFullPath = false) { if (defined('PHPFOX_INSTALLER')) { if (is_array($aParams)) { $aParams['sessionid'] = Phpfox_Installer::getSessionId(); } else { $aParams = array($aParams, 'sessionid' => Phpfox_Installer::getSessionId()); } } if (preg_match('/http:\/\//i', $sUrl)) { return $sUrl; } if ($sUrl == 'current') { $sUrl = ''; foreach ($this->_aParams as $sKey => $sValue) { if (substr($sKey, 0, 3) == 'req') { $sUrl .= $sValue . '.'; } else { $sUrl .= $sKey . '_' . $sValue . '.'; } } } (($sPlugin = Phpfox_Plugin::get('check_url_is_array')) ? eval($sPlugin) : false); // Make it an array if its not an array already (Used as shortcut) if (!is_array($aParams)) { $aParams = array($aParams); } if (!defined('PHPFOX_INSTALLER')) { if ($sUrl == 'profile') { if (empty($aParams[0]) && isset($aParams[1]) && $aParams[1] > 0) { $sUrl = ''; $sUrl .= 'pages'; } else { $sUrl = ''; $sUrl .= (isset($aParams[0]) ? $aParams[0] : Phpfox::getUserBy('user_name')); unset($aParams[0]); } } else { if (Phpfox::isUser() && preg_match("/profile/i", $sUrl)) { $aParts = explode('.', $sUrl); if (isset($aParts[0]) && $aParts[0] == 'profile') { unset($aParts[0]); if (isset($aParts[1]) && $aParts[1] == 'my') { unset($aParts[1]); } $sUrl = ''; /* if (Phpfox::getParam('user.profile_use_id')) { $sUrl .= 'profile.'; } */ $sUrl .= (isset($aParams[0]) ? $aParams[0] : Phpfox::getUserBy('user_name')); $sUrl .= '.' . implode('.', $aParts); } } } if ($sUrl == 'profile' && Phpfox::getParam('core.module_core') == PHPFOX_MODULE_CORE) { $sUrl = ''; } } $sUrl = trim($sUrl, '.'); $sUrls = ''; if ($sUrl == 'phpfox_full_site') { $sUrl = ''; } else { if ($this->isMobile()) { $sUrl = 'mobile.' . $sUrl; } } switch (Phpfox::getParam('core.url_rewrite')) { // www.site.com/foo/bar/ case 1: $aParts = explode('.', $sUrl); if ($bFullPath) { $sUrls .= Phpfox::getParam('core.path'); } $sUrls .= Phpfox::getParam('core.path'); $sUrls .= $this->_makeUrl($aParts, $aParams); break; // www.site.com/index.php?foo=bar case 2: $aParts = explode('.', $sUrl); if ($bFullPath) { $sUrls .= Phpfox::getParam('core.path'); } $sUrls .= Phpfox::getParam('core.path') . PHPFOX_INDEX_FILE . '?' . PHPFOX_GET_METHOD . '=/'; $sUrls .= $this->_makeUrl($aParts, $aParams); break; // foo.site.com/bar/ case 3: if (empty($sUrl)) { $sUrl = 'www'; } $aParts = explode('.', $sUrl); if (isset($this->aRewrite[$aParts[0]]) && !is_array($this->aRewrite[$aParts[0]])) { $aParts[0] = $this->aRewrite[$aParts[0]]; } $sUrls = preg_replace("/http:\/\/(.*?)\.(.*?)/i", "http://{$aParts[0]}.$2", Phpfox::getParam('core.path')); $sUrls .= $this->_makeUrl($aParts, $aParams); break; } if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.force_https_secure_pages')) { if (in_array($sUrl, Phpfox::getService('core')->getSecurePages())) { $sUrls = str_replace('http://', 'https://', $sUrls); } else { $sUrls = str_replace('https://', 'http://', $sUrls); } } (($sPlugin = Phpfox_Plugin::get('check_url_is_array_return')) ? eval($sPlugin) : false); return $sUrls; }
/** * Make an internal link. * * @param string $sUrl Internal link. * @param array $aParams ARRAY of params to include in the link. * @param bool $bFullPath Not using this argument any longer. * @return string Full URL. */ public function makeUrl($sUrl, $aParams = array(), $bFullPath = false) { $sUrl = trim($sUrl, '/'); if (defined('PHPFOX_INSTALLER')) { if (is_array($aParams)) { $aParams['sessionid'] = Phpfox_Installer::getSessionId(); } else { $aParams = array($aParams, 'sessionid' => Phpfox_Installer::getSessionId()); } } if (preg_match('/https?:\\/\\//i', $sUrl)) { return $sUrl; } if ($sUrl == 'current') { $sUrl = ''; foreach ($this->_aParams as $sKey => $sValue) { if (substr($sKey, 0, 3) == 'req') { $sUrl .= urlencode($sValue) . '.'; } else { // $sUrl .= $sKey . '_' . urlencode($sValue) . '.'; $aParams[$sKey] = $sValue; } } $aGets = $_GET; unset($aGets['do']); if ($aGets) { if (!is_array($aParams)) { $aParams = []; } $aParams = array_merge($aParams, $aGets); } $sUrl = rtrim($sUrl, '.'); } ($sPlugin = Phpfox_Plugin::get('check_url_is_array')) ? eval($sPlugin) : false; // Make it an array if its not an array already (Used as shortcut) if (!is_array($aParams)) { $aParams = array($aParams); } if (!defined('PHPFOX_INSTALLER')) { if ($sUrl == 'profile') { if (empty($aParams[0]) && isset($aParams[1]) && $aParams[1] > 0) { $sUrl = ''; $sUrl .= 'pages'; } else { $sUrl = ''; $sUrl .= isset($aParams[0]) ? $aParams[0] : Phpfox::getUserBy('user_name'); unset($aParams[0]); } } else { if (Phpfox::isUser() && preg_match("/profile/i", $sUrl)) { $aParts = explode('.', $sUrl); if (isset($aParts[0]) && $aParts[0] == 'profile') { unset($aParts[0]); if (isset($aParts[1]) && $aParts[1] == 'my') { unset($aParts[1]); } $sUrl = ''; /* if (Phpfox::getParam('user.profile_use_id')) { $sUrl .= 'profile.'; } */ $sUrl .= isset($aParams[0]) ? $aParams[0] : Phpfox::getUserBy('user_name'); $sUrl .= '.' . implode('.', $aParts); } } } if ($sUrl == 'profile' && Phpfox::getParam('core.module_core') == PHPFOX_MODULE_CORE) { $sUrl = ''; } } $sUrl = trim($sUrl, '.'); $sUrls = ''; switch (Phpfox::getParam('core.url_rewrite')) { // www.site.com/foo/bar/ case 1: case 2: $aParts = explode('.', $sUrl); $sUrls .= Phpfox::getParam('core.path'); $sUrls .= $this->_makeUrl($aParts, $aParams); break; // www.site.com/index.php?foo=bar /* case 2: $aParts = explode('.', $sUrl); if ($bFullPath) { $sUrls .= Phpfox::getParam('core.path'); } $sUrls .= Phpfox::getParam('core.path') . PHPFOX_INDEX_FILE . '?' . PHPFOX_GET_METHOD . '=/'; $sUrls .= $this->_makeUrl($aParts, $aParams); break; */ } if (!defined('PHPFOX_INSTALLER') && Phpfox::getParam('core.force_https_secure_pages')) { if (Phpfox::getParam('core.force_secure_site')) { $sUrls = str_replace('http://', 'https://', $sUrls); } else { if (in_array(str_replace('mobile.', '', $sUrl), Phpfox::getService('core')->getSecurePages())) { $sUrls = str_replace('http://', 'https://', $sUrls); } else { $sUrls = str_replace('https://', 'http://', $sUrls); } } } ($sPlugin = Phpfox_Plugin::get('check_url_is_array_return')) ? eval($sPlugin) : false; if (defined('PHPFOX_IS_HOSTED_SCRIPT') && defined('PHPFOX_IS_HOSTED_VERSION')) { $sUrls = str_replace('/' . PHPFOX_IS_HOSTED_VERSION . '/', '/', $sUrls); } return $sUrls; }