<h1><?php echo $I18N->msg('seo42_help_codeexamples'); ?> </h1> <?php $codeExample1 = '<?php echo rex_getUrl(42); // --> ' . seo42::getUrlStart() . 'questions/the-ultimate-answer.html echo seo42::getFullUrl(42); // --> ' . seo42::getServerUrl() . 'questions/the-ultimate-answer.html echo seo42::getMediaFile("image.png"); // --> ' . seo42::getUrlStart() . $REX['MEDIA_DIR'] . '/image.png echo seo42::getMediaUrl("image.png"); // --> ' . seo42::getMediaUrl('image.png') . ' echo seo42::getAbsoluteMediaFile("image.png"); // --> ' . seo42::getAbsoluteMediaFile('image.png') . ' echo seo42::getDownloadFile("doc.pdf"); // --> ' . seo42::getUrlStart() . seo42::downloadDir . '/doc.pdf ?>'; $codeExample2 = ' <link rel="stylesheet" href="<?php echo seo42::getCombinedCSSFile("combined.css", array("foo.css", "bar.scss", "batz.less")); ?>" type="text/css" media="screen" /> <link rel="stylesheet" href="<?php echo seo42::getCSSFile("default.css"); ?>" type="text/css" media="screen,print" /> <link rel="stylesheet" href="<?php echo seo42::getCSSFile("theme.scss"); ?>" type="text/css" media="screen,print" /> <link rel="stylesheet" href="<?php echo seo42::getCSSFile("stuff.less", array("color" => "red", "base" => "960px")); ?>" type="text/css" media="screen" /> <link rel="stylesheet" href="<?php echo seo42::getCSSFile("http://fonts.googleapis.com/css?family=Fjalla+One"); ?>" type="text/css" media="screen" />
/** * BUILD SINGLE XML LOC FRAGMENT * * @param $loc (string) full article url [including lang] * @param $lastmod (string) article last modified date [UNIX date] * @param $changefreq (string) change frequency [never|yearly|monthly|weekly|daily|hourly|always] * @param $priority (float) priority [maximum: 1.0] * * @return (string) xml location fragment */ private function xml_loc_fragment($loc, $lastmod, $changefreq, $priority) { $xml_loc = "\t" . '<url>' . PHP_EOL . "\t\t" . '<loc>' . seo42::getServerUrl() . seo42::trimUrl($loc) . '</loc>' . PHP_EOL . "\t\t" . '<lastmod>' . $lastmod . '</lastmod>' . PHP_EOL . "\t\t" . '<changefreq>' . $changefreq . '</changefreq>' . PHP_EOL . "\t\t" . '<priority>' . number_format($priority, 1, ".", "") . '</priority>' . PHP_EOL . "\t" . '</url>' . PHP_EOL; return $xml_loc; }
public static function noDoubleContentRedirect() { global $REX; if ($REX['ADDON']['seo42']['settings']['no_double_content_redirects'] == SEO42_NO_DOUBLE_CONTENT_REDIRECT_NONE) { // do nothing return; } elseif ($REX['ADDON']['seo42']['settings']['no_double_content_redirects_availability'] == SEO42_NO_DOUBLE_CONTENT_REDIRECT_AVAILABILITY_FRONTEND && $REX['REDAXO']) { // do nothing return; } elseif (isset($REX['SETUP']) && $REX['SETUP']) { // do nothing return; } else { // todo: here now seo42 methods can be used! $urlParts = parse_url($REX['SERVER']); if (isset($urlParts['scheme'])) { $protocol = $urlParts['scheme']; } else { $protocol = 'http'; } if (isset($urlParts['host'])) { $server = $urlParts['host']; } else { $server = $REX['SERVER']; } $location = ''; $serverHost = self::getServerHost(); $requestUri = $_SERVER['REQUEST_URI']; if (self::isHttps()) { $curProtocol = 'https'; } else { $curProtocol = 'http'; } // check for possible protocol only redirect if ($curProtocol != $protocol) { $location = $protocol . '://' . $serverHost . $requestUri; } switch ($REX['ADDON']['seo42']['settings']['no_double_content_redirects']) { case SEO42_NO_DOUBLE_CONTENT_REDIRECT_ONE_DOMAIN_ONLY: // one domain only (when website manager ist installed this redirect is not allowed) if ($serverHost != $server) { // don't redirect if server url is empty, or default value or not full url if (self::isWebsiteUrlValid(seo42::getServerUrl())) { $location = $protocol . '://' . $server . $requestUri; } } break; case SEO42_NO_DOUBLE_CONTENT_REDIRECT_NON_WWW_TO_WWW: // non-www to www if (preg_match('/^[^.]+\\.[^.]+$/', $serverHost, $hits)) { $location = $protocol . '://www.' . $hits[0] . $requestUri; } break; case SEO42_NO_DOUBLE_CONTENT_REDIRECT_WWW_TO_NON_WWW: // www to non-www if (preg_match('/^www\\.(.*)$/', $serverHost, $hits)) { $location = $protocol . '://' . substr($hits[0], 4) . $requestUri; } break; case SEO42_NO_DOUBLE_CONTENT_REDIRECT_ONLY_HTTPS: // https only $urlParts = parse_url($serverHost); if ($curProtocol == 'http') { $location = 'https://' . $serverHost . $requestUri; } break; } if ($location != '') { header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $location); exit; } } }
case 'download': error_reporting(0); @ini_set('display_errors', 0); if (isset($REX['ADDON']['seo42']['settings']['force_download_for_filetypes']) && is_array($REX['ADDON']['seo42']['settings']['force_download_for_filetypes']) && count($REX['ADDON']['seo42']['settings']['force_download_for_filetypes']) > 0 && isset($_GET["file"])) { $file = strtolower(preg_replace("/[^a-zA-Z0-9.\\-\$\\+]/", "_", rex_get('file', 'string'))); $file = urlencode(basename($file)); $fileWithPath = realpath('./' . $REX['MEDIA_DIR'] . '/' . $file); $pathInfo = pathinfo($fileWithPath); if (isset($pathInfo['extension']) && in_array($pathInfo['extension'], $REX['ADDON']['seo42']['settings']['force_download_for_filetypes']) && file_exists($fileWithPath)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . $file); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Link: <' . seo42::getServerUrl() . ltrim(seo42::getMediaFile($file), "./") . '>; rel="canonical"'); header('Content-Length: ' . filesize($fileWithPath)); ob_clean(); flush(); readfile($fileWithPath); exit; } } break; case 'googlesiteverification': $googleSiteVerificationFile = strtolower(preg_replace("/[^a-zA-Z0-9.\\-\$\\+]/", "_", trim(trim($REX['ADDON']['seo42']['settings']['google_site_verification_filename']), '/'))); $requestedFile = strtolower(preg_replace("/[^a-zA-Z0-9.\\-\$\\+]/", "_", trim($_SERVER['REQUEST_URI'], '/'))); if ($googleSiteVerificationFile != '' && $requestedFile == $googleSiteVerificationFile) { ob_clean(); flush(); echo 'google-site-verification: ' . $googleSiteVerificationFile;
/** * REDIRECT() * * redirect request * @param $redirect (array) params passed through from EP */ protected function redirect($redirect) { global $SEO42_IDS; $base = seo42::getServerUrl(); $status = isset($redirect['status']) ? $redirect['status'] : 200; $location = $base . $SEO42_IDS[$redirect['id']][$redirect['clang']]['url']; while (ob_get_level()) { ob_end_clean(); } if ($status == 301) { header('HTTP/1.1 301 Moved Permanently'); } else { header('HTTP/1.1 ' . $status); } header('Location:' . $location); exit; }
' . $I18N->msg('seo42_settings_language') . ' </span> ' . $homelang_select->get() . ' '; } else { $homelang_box = ''; } $auto_redirects_select = new rex_select(); $auto_redirects_select->setSize(1); $auto_redirects_select->setName('settings[auto_redirects]'); $auto_redirects_select->addOption($I18N->msg('seo42_settings_auto_redirects_0'), SEO42_AUTO_REDIRECT_NONE); $auto_redirects_select->addOption($I18N->msg('seo42_settings_auto_redirects_1'), SEO42_AUTO_REDIRECT_ARTICLE_ID); $auto_redirects_select->addOption($I18N->msg('seo42_settings_auto_redirects_2'), SEO42_AUTO_REDIRECT_URL_REWRITE); $auto_redirects_select->addOption($I18N->msg('seo42_settings_auto_redirects_3'), SEO42_AUTO_REDIRECT_URL_REWRITE_R3); $auto_redirects_select->setSelected($REX['ADDON'][$myself]['settings']['auto_redirects']); if (seo42_utils::isWebsiteUrlValid(seo42::getServerUrl())) { $serverString = seo42::getServer(); } else { $serverString = $I18N->msg('seo42_settings_no_double_content_redirects_1_invalid'); } $no_double_content_redirects_select = new rex_select(); $no_double_content_redirects_select->setSize(1); $no_double_content_redirects_select->setName('settings[no_double_content_redirects]'); $no_double_content_redirects_select->addOption($I18N->msg('seo42_settings_no_double_content_redirects_0'), SEO42_NO_DOUBLE_CONTENT_REDIRECT_NONE); $no_double_content_redirects_select->addOption($I18N->msg('seo42_settings_no_double_content_redirects_1') . ' [' . $serverString . '] ' . $I18N->msg('seo42_settings_no_double_content_redirects_1a'), SEO42_NO_DOUBLE_CONTENT_REDIRECT_ONE_DOMAIN_ONLY); $no_double_content_redirects_select->addOption($I18N->msg('seo42_settings_no_double_content_redirects_2'), SEO42_NO_DOUBLE_CONTENT_REDIRECT_NON_WWW_TO_WWW); $no_double_content_redirects_select->addOption($I18N->msg('seo42_settings_no_double_content_redirects_3'), SEO42_NO_DOUBLE_CONTENT_REDIRECT_WWW_TO_NON_WWW); $no_double_content_redirects_select->addOption($I18N->msg('seo42_settings_no_double_content_redirects_4'), SEO42_NO_DOUBLE_CONTENT_REDIRECT_ONLY_HTTPS); $no_double_content_redirects_select->setSelected($REX['ADDON'][$myself]['settings']['no_double_content_redirects']); $no_double_content_redirects_availability_select = new rex_select(); $no_double_content_redirects_availability_select->setSize(1);