/** * create a url for requested or static block **/ function GetUrl($data = '', $onclick = true) { global $scripturl, $boardurl; $baseurl = function_exists('pmxsef_query') ? $boardurl . '/' : $scripturl . '?'; $data = strpos($data, 'child') !== false && !empty($this->postarray[$this->postKey]['cat']) ? 'cat=' . $this->postarray[$this->postKey]['cat'] . ';' . $data : $data; $data = function_exists('create_sefurl') ? str_replace($baseurl, '', create_sefurl($scripturl . '?' . $data)) : $data; return (!empty($data) ? $baseurl . $data . '"' : '') . (!empty($onclick) ? ' onclick="pmx_StaticBlockSub(\'' . $this->postKey . '\', this, \'/' . rtrim($baseurl, '?/') . '/\', \'' . $this->cfg['uniID'] . '\')"' : ''); }
function ob_pmxsef($buffer) { global $scripturl, $boardurl, $PortaMxSEF, $pmxCacheFunc, $modSettings; if (!empty($_REQUEST['pmxcook'])) { return $buffer; } if (!empty($modSettings['pmxportal_disabled']) || !empty($modSettings['pmxsef_disabled'])) { return $buffer; } // convert SSEF simple url's if (!empty($PortaMxSEF['ssefspace'])) { $matches = array(); preg_match_all('~(\\b' . preg_quote($boardurl) . '\\/(topic' . $PortaMxSEF['ssefspace'] . '([a-zA-Z0-9\\.]+)|board' . $PortaMxSEF['ssefspace'] . '([a-zA-Z0-9\\.]+)))~', $buffer, $matches); if (!empty($matches[2])) { $replacements = array(); // topics.. $seftopics = array_diff(array_unique($matches[3]), array('')); foreach ($seftopics as $i => $url) { $replacements[$matches[2][$i]] = rtrim(getTopicName($url), '/'); } // boards $sefboards = array_diff(array_unique($matches[4]), array('')); foreach ($sefboards as $i => $url) { $replacements[$matches[2][$i]] = rtrim(getBoardName($url), '/'); } $buffer = str_replace(array_keys($replacements), array_values($replacements), $buffer); } } // fix expandable pagelinks $buffer = str_replace('/index.php\'+\'?', '/index.php?', $buffer); // Get all topics.. $matches = array(); preg_match_all('~\\b' . preg_quote($scripturl) . '.*?topic=([0-9]+)~', $buffer, $matches); if (!empty($matches[1])) { getTopicNameList(array_unique($matches[1])); } // Get all user.. $matches = array(); preg_match_all('~\\b' . preg_quote($scripturl) . '.*?u=([0-9]+)~', $buffer, $matches); if (!empty($matches[1])) { getUserNameList(array_unique($matches[1])); } // Do the rest of the URLs, skip admin urls $matches = array(); preg_match_all('~\\b(' . preg_quote($scripturl) . '(?!\\?action=admin)(?!\\?action=portamx)[-a-zA-Z0-9+&@#/%?=\\~_|!:,.;\\[\\]]*[-a-zA-Z0-9+&@#/%=\\~_|\\[\\]]?)([^-a-zA-Z0-9+&@#/%=\\~_|])~', $buffer, $matches); if (!empty($matches[0])) { $replacements = array(); foreach (array_unique($matches[1]) as $i => $url) { $replace = create_sefurl($url); if ($url != $replace) { $replacements[$matches[0][$i]] = $replace . str_replace(';', '', $matches[2][$i]); } } $buffer = str_replace(array_keys($replacements), array_values($replacements), $buffer); } // Gotta fix up some javascript laying around in the templates $extra_replacements = array('%1/$d' => '%1$d/', '/$d\',' => '_%1$d/\',', '/rand,' => '/rand=', '%1.html$d\',' => '%1$d.html\',', $boardurl . '/topic/' => $scripturl . '?topic=', '%1_%1$d/\',' => '%1$d/\',', 'var smf_scripturl = "' . $boardurl . '/' => 'var smf_scripturl = "' . $scripturl); $buffer = str_replace(array_keys($extra_replacements), array_values($extra_replacements), $buffer); // Check to see if we need to update the actions lists if (!empty($PortaMxSEF['autosave']) && count(explode(',', $modSettings['pmxsef_actions'])) != count($PortaMxSEF['actions'])) { $changeArray['pmxsef_actions'] = implode(',', array_filter(array_unique($PortaMxSEF['actions']))); updateSettings($changeArray); $pmxCacheFunc['clr']('sef_settings', false); } // done return $buffer; }