Single place to handle redirection.

This commit is contained in:
Michal Čihař
2011-01-31 15:21:37 +01:00
parent 14ebfdbe8e
commit 67e4994490
13 changed files with 40 additions and 25 deletions

View File

@@ -192,7 +192,7 @@ if (top != self) {
?> ?>
<div class="container"> <div class="container">
<a href="./url.php?url=http://www.phpmyadmin.net" target="_blank" class="logo"><?php <a href="<?php echo PMA_linkURL('http://www.phpmyadmin.net/'); ?>" target="_blank" class="logo"><?php
$logo_image = $GLOBALS['pmaThemeImage'] . 'logo_right.png'; $logo_image = $GLOBALS['pmaThemeImage'] . 'logo_right.png';
if (@file_exists($logo_image)) { if (@file_exists($logo_image)) {
echo '<img src="' . $logo_image . '" id="imLogo" name="imLogo" alt="phpMyAdmin" border="0" />'; echo '<img src="' . $logo_image . '" id="imLogo" name="imLogo" alt="phpMyAdmin" border="0" />';

View File

@@ -231,7 +231,7 @@ function Swekey_login($input_name, $input_go)
?> ?>
function open_swekey_site() function open_swekey_site()
{ {
window.open("./url.php?url=http://phpmyadmin.net/auth_key"); window.open("<?php echo PMA_linkURL('http://phpmyadmin.net/auth_key'); ?>");
} }
var input_username = document.getElementById("<?php echo $input_name; ?>"); var input_username = document.getElementById("<?php echo $input_name; ?>");

View File

@@ -497,7 +497,7 @@ function PMA_BS_getURL($reference)
return FALSE; return FALSE;
} }
$bs_url = './url.php?url=http://' . $bs_server . '/' . rtrim($reference); $bs_url = PMA_linkURL('http://' . $bs_server . '/' . rtrim($reference));
return $bs_url; return $bs_url;
} }

View File

@@ -419,13 +419,13 @@ function PMA_showMySQLDocu($chapter, $link, $big_icon = false, $anchor = '', $ju
} }
if ($just_open) { if ($just_open) {
return '<a href="./url.php?url=' . $url . '" target="mysql_doc">'; return '<a href="' . PMA_linkURL($url) . '" target="mysql_doc">';
} elseif ($big_icon) { } elseif ($big_icon) {
return '<a href="./url.php?url=' . $url . '" target="mysql_doc"><img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_sqlhelp.png" width="16" height="16" alt="' . __('Documentation') . '" title="' . __('Documentation') . '" /></a>'; return '<a href="' . PMA_linkURL($url) . '" target="mysql_doc"><img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_sqlhelp.png" width="16" height="16" alt="' . __('Documentation') . '" title="' . __('Documentation') . '" /></a>';
} elseif ($GLOBALS['cfg']['ReplaceHelpImg']) { } elseif ($GLOBALS['cfg']['ReplaceHelpImg']) {
return '<a href="./url.php?url=' . $url . '" target="mysql_doc"><img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_help.png" width="11" height="11" alt="' . __('Documentation') . '" title="' . __('Documentation') . '" /></a>'; return '<a href="' . PMA_linkURL($url) . '" target="mysql_doc"><img class="icon" src="' . $GLOBALS['pmaThemeImage'] . 'b_help.png" width="11" height="11" alt="' . __('Documentation') . '" title="' . __('Documentation') . '" /></a>';
} else { } else {
return '[<a href="./url.php?url=' . $url . '" target="mysql_doc">' . __('Documentation') . '</a>]'; return '[<a href="' . PMA_linkURL($url) . '" target="mysql_doc">' . __('Documentation') . '</a>]';
} }
} // end of the 'PMA_showMySQLDocu()' function } // end of the 'PMA_showMySQLDocu()' function
@@ -2425,7 +2425,7 @@ function PMA_getDbLink($database = null)
function PMA_externalBug($functionality, $component, $minimum_version, $bugref) function PMA_externalBug($functionality, $component, $minimum_version, $bugref)
{ {
if ($component == 'mysql' && PMA_MYSQL_INT_VERSION < $minimum_version) { if ($component == 'mysql' && PMA_MYSQL_INT_VERSION < $minimum_version) {
echo PMA_showHint(sprintf(__('The %s functionality is affected by a known bug, see %s'), $functionality, './url.php?url=http://bugs.mysql.com/' . $bugref)); echo PMA_showHint(sprintf(__('The %s functionality is affected by a known bug, see %s'), $functionality, PMA_linkURL('http://bugs.mysql.com/') . $bugref));
} }
} }

View File

@@ -681,7 +681,7 @@ class FormDisplay
if ($test == 'Export') { if ($test == 'Export') {
$opt_name = substr($opt_name, 7); $opt_name = substr($opt_name, 7);
} }
return './url.php?url=http://wiki.phpmyadmin.net/pma/Config#' . $opt_name; return PMA_linkURL('http://wiki.phpmyadmin.net/pma/Config#' . $opt_name);
} }
/** /**

View File

@@ -93,10 +93,8 @@ function PMA_lang_link_replace($link, $text)
if (!preg_match('#^https?://#', $link)) { if (!preg_match('#^https?://#', $link)) {
$link = str_replace('&amp;', $separator, $link); $link = str_replace('&amp;', $separator, $link);
} elseif (defined('PMA_SETUP')) {
$link = '../url.php?url=' . $link;
} else { } else {
$link = './url.php?url=' . $link; $link = PMA_linkURL($link);
} }
return '<a href="' . $link . '">' . $text . '</a>'; return '<a href="' . $link . '">' . $text . '</a>';

View File

@@ -656,4 +656,21 @@ function PMA_array_remove($path, &$array)
} }
} }
} }
/**
* Returns link to (possibly) external site using defined redirector.
*
* @param string $url URL where to go.
*
* @return string URL for a link.
*/
function PMA_linkURL($url) {
if (!preg_match('#^https?://#', $url)) {
return $url;
} elseif (defined('PMA_SETUP')) {
return '../url.php?url=' . $url;
} else {
return './url.php?url=' . $url;
}
}
?> ?>

View File

@@ -235,7 +235,7 @@ if(isset($_GET['sql_query'])) {
} }
$message = new PMA_Message(__('This value is interpreted using %1$sstrftime%2$s, so you can use time formatting strings. Additionally the following transformations will happen: %3$s. Other text will be kept as is. See the %4$sFAQ%5$s for details.')); $message = new PMA_Message(__('This value is interpreted using %1$sstrftime%2$s, so you can use time formatting strings. Additionally the following transformations will happen: %3$s. Other text will be kept as is. See the %4$sFAQ%5$s for details.'));
$message->addParam('<a href="./url.php?url=http://php.net/strftime" target="documentation" title="' $message->addParam('<a href="' . PMA_linkURL('http://php.net/strftime') . '" target="documentation" title="'
. __('Documentation') . '">', false); . __('Documentation') . '">', false);
$message->addParam('</a>', false); $message->addParam('</a>', false);
$message->addParam($trans); $message->addParam($trans);

View File

@@ -91,15 +91,15 @@ class PMA_StorageEngine_pbms extends PMA_StorageEngine
function getPageDocumentation() function getPageDocumentation()
{ {
$output = '<p> Documentation and further information about PBMS can be found on ' . "\n" $output = '<p> Documentation and further information about PBMS can be found on ' . "\n"
. '<a href="./url.php?url=http://www.blobstreaming.org/" target="_blank">The PrimeBase Media Streaming home page</a>.<br><br>' . "\n" . '<a href="' . PMA_linkURL('http://www.blobstreaming.org/') . '" target="_blank">The PrimeBase Media Streaming home page</a>.<br><br>' . "\n"
. '<table id="PBMS_Related_Links" >' . "\n" . '<table id="PBMS_Related_Links" >' . "\n"
. '<tr>' . "\n" . '<tr>' . "\n"
. '<td>' . "\n" . '<td>' . "\n"
. '<p>' . "\n" . '<p>' . "\n"
. '<strong><font size="2"><b>Related Links</b></font></strong>' . "\n" . '<strong><font size="2"><b>Related Links</b></font></strong>' . "\n"
. '<br>' . "\n" . '<br>' . "\n"
. '<a href="./url.php?url=http://bpbdev.blogspot.com/" target="_blank">The PrimeBase Media Streaming Blog by Barry Leslie</a><br><br>' . "\n" . '<a href="' . PMA_linkURL('http://bpbdev.blogspot.com/') . '" target="_blank">The PrimeBase Media Streaming Blog by Barry Leslie</a><br><br>' . "\n"
. '<a href="./url.php?url=http://www.primebase.com/xt" target="_blank">PrimeBase XT Home Page</a><br><br>' . "\n" . '<a href="' . PMA_linkURL('http://www.primebase.com/xt') . '" target="_blank">PrimeBase XT Home Page</a><br><br>' . "\n"
. '</font>' . "\n" . '</font>' . "\n"
. '</td>' . "\n" . '</td>' . "\n"
. '</tr>' . "\n" . '</tr>' . "\n"

View File

@@ -122,15 +122,15 @@ class PMA_StorageEngine_pbxt extends PMA_StorageEngine
function getPageDocumentation() function getPageDocumentation()
{ {
$output = '<p> Documentation and further information about PBXT can be found on the ' . "\n" $output = '<p> Documentation and further information about PBXT can be found on the ' . "\n"
. '<a href="./url.php?url=http://www.primebase.com/xt/" target="_blank">PrimeBase XT Home Page</a>.<br><br>' . "\n" . '<a href="' . PMA_linkURL('http://www.primebase.com/xt/') . '" target="_blank">PrimeBase XT Home Page</a>.<br><br>' . "\n"
. '<table id="PBMS_Related_Links" >' . "\n" . '<table id="PBMS_Related_Links" >' . "\n"
. '<tr>' . "\n" . '<tr>' . "\n"
. '<td>' . "\n" . '<td>' . "\n"
. '<p>' . "\n" . '<p>' . "\n"
. '<strong><font size="2"><b>Related Links</b></font></strong>' . "\n" . '<strong><font size="2"><b>Related Links</b></font></strong>' . "\n"
. '<br>' . "\n" . '<br>' . "\n"
. '<a href="./url.php?url=http://pbxt.blogspot.com/" target="_blank">The PrimeBase XT Blog by Paul McCullagh</a><br><br>' . "\n" . '<a href="' . PMA_linkURL('http://pbxt.blogspot.com/') . '" target="_blank">The PrimeBase XT Blog by Paul McCullagh</a><br><br>' . "\n"
. '<a href="./url.php?url=http://www.blobstreaming.org/" target="_blank">The PrimeBase Media Streaming (PBMS) home page</a>.<br><br>' . "\n" . '<a href="' . PMA_linkURL('http://www.blobstreaming.org/') . '" target="_blank">The PrimeBase Media Streaming (PBMS) home page</a>.<br><br>' . "\n"
. '</font>' . "\n" . '</font>' . "\n"
. '</td>' . "\n" . '</td>' . "\n"
. '</tr>' . "\n" . '</tr>' . "\n"

View File

@@ -74,7 +74,7 @@ function PMA_sanitize($message, $escape = false, $safe = false)
} }
if (substr($found[1], 0, 4) == 'http') { if (substr($found[1], 0, 4) == 'http') {
$message = preg_replace($pattern, '<a href="./url.php?url=\1" target="\2">', $message); $message = preg_replace($pattern, '<a href="' . PMA_linkURL($found[1]) . '" target="\2">', $message);
} else { } else {
$message = preg_replace($pattern, '<a href="\1" target="\2">', $message); $message = preg_replace($pattern, '<a href="\1" target="\2">', $message);
} }

View File

@@ -210,16 +210,16 @@ echo '<h2>phpMyAdmin</h2>';
echo '<ul>'; echo '<ul>';
PMA_printListItem(__('Version information') . ': ' . PMA_VERSION, 'li_pma_version'); PMA_printListItem(__('Version information') . ': ' . PMA_VERSION, 'li_pma_version');
PMA_printListItem(__('Documentation'), 'li_pma_docs', 'Documentation.html', null, '_blank'); PMA_printListItem(__('Documentation'), 'li_pma_docs', 'Documentation.html', null, '_blank');
PMA_printListItem(__('Wiki'), 'li_pma_wiki', './url.php?url=http://wiki.phpmyadmin.net', null, '_blank'); PMA_printListItem(__('Wiki'), 'li_pma_wiki', PMA_linkURL('http://wiki.phpmyadmin.net/'), null, '_blank');
// does not work if no target specified, don't know why // does not work if no target specified, don't know why
PMA_printListItem(__('Official Homepage'), 'li_pma_homepage', './url.php?url=http://www.phpMyAdmin.net/', null, '_blank'); PMA_printListItem(__('Official Homepage'), 'li_pma_homepage', PMA_linkURL('http://www.phpMyAdmin.net/'), null, '_blank');
?> ?>
<li><bdo xml:lang="en" dir="ltr"> <li><bdo xml:lang="en" dir="ltr">
[<a href="changelog.php" target="_blank">ChangeLog</a>] [<a href="changelog.php" target="_blank">ChangeLog</a>]
[<a href="./url.php?url=http://phpmyadmin.git.sourceforge.net/git/gitweb-index.cgi" [<a href="<?php echo PMA_linkURL('http://phpmyadmin.git.sourceforge.net/git/gitweb-index.cgi'); ?>"
target="_blank">Git</a>] target="_blank">Git</a>]
[<a href="./url.php?url=http://sourceforge.net/mail/?group_id=23067" [<a href="<?php echo PMA_linkURL('http://sourceforge.net/mail/?group_id=23067'); ?>"
target="_blank"><?php echo __('Mailing lists'); ?></a>] target="_blank"><?php echo __('Mailing lists'); ?></a>]
</bdo> </bdo>
</li> </li>

View File

@@ -38,7 +38,7 @@ function takeThis(what){
<body id="bodythemes"> <body id="bodythemes">
<h1>phpMyAdmin - <?php echo __('Theme / Style'); ?></h1> <h1>phpMyAdmin - <?php echo __('Theme / Style'); ?></h1>
<p><a href="./url.php?url=http://www.phpmyadmin.net/home_page/themes.php#pma_<?php echo preg_replace('/([0-9]*)\.([0-9]*)\..*/', '\1_\2', PMA_VERSION); ?>"><?php echo __('Get more themes!'); ?></a></p> <p><a href="<?php echo PMA_linkURL('http://www.phpmyadmin.net/home_page/themes.php'); ?>#pma_<?php echo preg_replace('/([0-9]*)\.([0-9]*)\..*/', '\1_\2', PMA_VERSION); ?>"><?php echo __('Get more themes!'); ?></a></p>
<?php <?php
$_SESSION['PMA_Theme_Manager']->printPreviews(); $_SESSION['PMA_Theme_Manager']->printPreviews();
?> ?>