21 $sUrl = $oStr->html_entity_decode( $sUrl );
23 if ( ( $iPos = strpos( $sUrl,
'?' ) ) !==
false ) {
24 parse_str( $oStr->substr( $sUrl, $iPos+1 ), $aRet );
38 protected function _getIdent( $sSeoUrl, $blIgnore =
false )
40 return md5( strtolower( $sSeoUrl ) );
55 $sBaseUrl = $this->
getConfig()->getShopURL();
56 if ( $oStr->strpos( $sSeoUrl, $sBaseUrl ) === 0 ) {
57 $sSeoUrl = $oStr->substr( $sSeoUrl, $oStr->strlen( $sBaseUrl ) );
59 $sSeoUrl = rawurldecode( $sSeoUrl );
60 $iShopId = $this->
getConfig()->getShopId();
66 $oRs = $oDb->select(
"select oxstdurl, oxlang from oxseo where oxident=" . $oDb->quote( $sKey ) .
" and oxshopid='$iShopId' limit 1");
69 $aRet = $this->
parseStdUrl( $oRs->fields[
'oxstdurl'] );
70 $aRet[
'lang'] = $oRs->fields[
'oxlang'];;
88 $sBaseUrl = $this->
getConfig()->getShopURL();
89 if ( $oStr->strpos( $sSeoUrl, $sBaseUrl ) === 0 ) {
90 $sSeoUrl = $oStr->substr( $sSeoUrl, $oStr->strlen( $sBaseUrl ) );
92 $iShopId = $this->
getConfig()->getShopId();
93 $sSeoUrl = rawurldecode($sSeoUrl);
95 $sKey = $this->
_getIdent( $sSeoUrl,
true );
98 $oRs = $oDb->select(
"select oxobjectid, oxlang from oxseohistory where oxident = " . $oDb->quote( $sKey ) .
" and oxshopid = '{$iShopId}' limit 1");
101 $oDb->execute(
"update oxseohistory set oxhits = oxhits + 1 where oxident = " . $oDb->quote( $sKey ) .
" and oxshopid = '{$iShopId}' limit 1" );
104 $sUrl = $this->
_getSeoUrl($oRs->fields[
'oxobjectid'], $oRs->fields[
'oxlang'], $iShopId);
122 if ( ( $sQ = $_SERVER[
"QUERY_STRING"] ) ) {
123 $sUrl = rtrim( $sUrl,
"&?" );
124 $sQ = ltrim( $sQ,
"&?" );
126 $sUrl .= ( strpos( $sUrl,
'?') === false ) ?
"?" :
"&";
145 $aInfo = $oDb->getRow(
"select oxseourl, oxtype from oxseo where oxobjectid = " . $oDb->quote( $sObjectId ) .
" and oxlang = " . $oDb->quote( $iLang ) .
" and oxshopid = " . $oDb->quote( $iShopId ) .
" order by oxparams limit 1" );
146 if (
'oxarticle' == $aInfo[
'oxtype']) {
147 $sMainCatId = $oDb->getOne(
"select oxcatnid from ".getViewName(
"oxobject2category" ).
" where oxobjectid = " . $oDb->quote( $sObjectId ) .
" order by oxtime" );
149 $sUrl = $oDb->getOne(
"select oxseourl from oxseo where oxobjectid = " . $oDb->quote( $sObjectId ) .
" and oxlang = " . $oDb->quote( $iLang ) .
" and oxshopid = " . $oDb->quote( $iShopId ) .
" and oxparams = " . $oDb->quote( $sMainCatId ) .
" order by oxexpired" );
156 return $aInfo[
'oxseourl'];
172 if ( isset( $_SERVER[
'REQUEST_URI'] ) && $_SERVER[
'REQUEST_URI'] ) {
173 $sRequest = $_SERVER[
'REQUEST_URI'];
176 $sRequest = $_SERVER[
'SCRIPT_URI'];
180 $sPath = $sPath ? $sPath : str_replace(
'oxseo.php',
'', $_SERVER[
'SCRIPT_NAME'] );
181 if ( ( $sParams = $this->
_getParams( $sRequest, $sPath ) ) ) {
184 if ( is_array( $aGet = $this->
decodeUrl( $sParams ) ) ) {
185 $_GET = array_merge( $aGet, $_GET );
187 } elseif ( ( $sRedirectUrl = $this->
_decodeOldUrl( $sParams ) ) ) {
196 error_404_handler( $sParams );
212 $sLastParam = rtrim( $sParams,
'/' );
213 $sLastParam = $oStr->substr( $sLastParam, ( (
int ) strrpos( $sLastParam,
'/' ) ) - ( $oStr->strlen( $sLastParam ) ) );
214 $sLastParam = trim( $sParams,
'/' );
224 if ( strpos( $sLastParam,
'.htm' ) !==
false ) {
225 $sUrl = $this->
_getObjectUrl( $sLastParam,
'oxarticles', $iLanguage,
'oxarticle' );
229 if ( !( $sUrl = $this->
_getObjectUrl( $sLastParam,
'oxcategories', $iLanguage,
'oxcategory' ) ) ) {
231 if ( !( $sUrl = $this->
_getObjectUrl( $sLastParam,
'oxmanufacturers', $iLanguage,
'oxmanufacturer' ) ) ) {
233 $sUrl = $this->
_getObjectUrl( $sLastParam,
'oxvendor', $iLanguage,
'oxvendor' );
255 $sTable = getViewName( $sTable, $iLanguage );
259 if ( $oDb->getOne(
"show columns from {$sTable} where field = 'oxseoid'" ) ) {
261 if ( $sObjectId = $oDb->getOne(
"select oxid from {$sTable} where oxseoid = ".$oDb->quote( $sSeoId ) ) ) {
262 $sSeoUrl = $oDb->getOne(
"select oxseourl from oxseo where oxtype = " . $oDb->quote( $sType ) .
" and oxobjectid = " . $oDb->quote( $sObjectId ) .
" and oxlang = " . $oDb->quote( $iLanguage ) .
" " );
281 $sParams = $oStr->preg_replace(
'/\?.*/',
'', $sRequest );
282 $sPath = preg_quote($sPath,
'/');
283 $sParams = $oStr->preg_replace(
"/^$sPath/",
'', $sParams );
286 if ( $sParams && !$oStr->preg_match(
'/\.html$/', $sParams ) && !$oStr->preg_match(
'/\/$/', $sParams ) ) {