Skip to content
Snippets Groups Projects
Commit 8d9f54b8 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

update admin

parent 0726b442
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,7 @@
* admin: list all defined redirections
* ----------------------------------------------------------------------
* 2022-02-03 v0.1 <axel.hahn@iml.unibe.ch> initial version
* 2022-05-21 v0.2 <axel.hahn@iml.unibe.ch> optical changes; use debugredirect=1 if url is a local domain
* ----------------------------------------------------------------------
*/
......@@ -61,7 +62,7 @@ if (!$oR->isEnabled()){
$sUrl=(isset($_GET['url']) && $_GET['url']) ? $_GET['url'] : '';
if ($sUrl){
$sResult=$oR->httpGet($sUrl.'?debugredirect=1',1);
$sResult=$oR->httpGet($sUrl,1);
echo '<h2>Response of a http HEAD request to '.$aIco['url'].' <a href="'.$sUrl.'">'.$sUrl.'</a></h2>'
. $oR->renderHttpResponseHeader($sResult, 1)
;
......@@ -80,7 +81,6 @@ if (!$oR->isEnabled()){
exit(0);
}
$sMyIp=gethostbyname($_SERVER['SERVER_NAME']);
if(!$sMyIp){
$sErrors.='<li>Ip address of current host ['.$_SERVER['SERVER_NAME'].'] was not found.</li>';
......@@ -130,7 +130,9 @@ if (!$oR->isEnabled()){
.'<td>'
.'<span style="display: none">'.$sHost.'</span>'
.$aIco['type_'.$aCfg['type']]
.' <a href="?url=http://'.$sHost.'/" title="click to test http://'.$sHost.'/" onclick="showInOverlay(this); return false;">'.$sHost.'</a></td>'
.' <a href="?url=http://'.$sHost.'/'
.($aCfg['ip']===$sMyIp ? '?debugredirect=1' : '' )
.'" title="click to test http://'.$sHost.'/" onclick="showInOverlay(this); return false;">'.$sHost.'</a></td>'
.'<td>'
.($aCfg['ip']
? ($aCfg['ip']===$sMyIp
......@@ -142,7 +144,7 @@ if (!$oR->isEnabled()){
.'<td>'
.($aCfg['type']=="config"
? '<a href="?cfgfile=redirects_'.$sHost.'.json" onclick="showInOverlay(this); return false;" title="show config for host '.$sHost.'">'.$aCfg['type'].'</a> '
: $aCfg['type']
: '<a href="?cfgfile=redirects_'.$aCfg['target'].'.json" onclick="showInOverlay(this); return false;" title="show config for alias '.$sHost.' pointing to host '.$aCfg['target'].'">'.$aCfg['type'].'</a> '
)
. '</td>'
;
......
......@@ -2,14 +2,15 @@ a{color:royalblue;}
body{background: #f8f8f8; color: #234; font-family: arial; margin: 0;}
h1{background:rgba(0,0,0,0.05); margin: 0 0 1em;; padding: 0.5em;}
h1 a{color:#234; text-decoration: none;}
h2{background:rgba(0,0,0,0.02); color:#458; margin: 1em 0 0.5em; border-top: 2px solid #fff; border-left: 5px solid #fff; border-top-left-radius: 0.5em; padding: 0.5em; }
h2{background: #d0e0e8; color:#458; margin: 1em 0 0.5em; border-top: 2px solid #fff; border-left: 5px solid #fff; border-top-left-radius: 0.5em; padding: 0.5em; }
pre{background: rgba(0,0,0,0.02);padding: 0.3em 1em; border: 1px solid rgba(0,0,0,0.1); margin-bottom: 2em;}
pre{background: rgba(0,0,0,0.02);padding: 0.3em 1em; border: 1px solid rgba(0,0,0,0.1); margin: 2em 0 3em;; border-bottom: 2px solid rgba(0,0,0,0.2);}
tr:hover{background: #f4f0f8 !important;}
.content{margin: 0 1em;}
.error{background: #fcc;}
.warning{color:#651; background:#fec;}
.cfgtype-alias{color:#89a;}
.http-301::after{color:#a55; content: ' (Moved Permanently)'}
......@@ -18,14 +19,15 @@ tr:hover{background: #f4f0f8 !important;}
.type-direct{color:#383; }
.type-regex{color:#838; }
.status{padding: 0.5em 1em; position: relative;top: -0.8em; border: 2px solid; border-left: 1.5em solid;}
.status{padding: 0.5em 1em; position: relative;top: -0.8em; border-left: 2px solid; border-left_: 1.5em solid;font-size: 125%;}
.status-ok{color:#080; background:#cec; }
.status-redirect{color:#651; background:#fec;}
.status-error{color:#800; background:#ecc;}
.location{background:#fec;}
.location{background:#cde; border: 1px solid rgba(0,0,0,0.2); font-size: 125%; color:#236;}
.location::before{content:' > '; color:#800; background-color: #fff;}
.debug{color:#197;}
.overlay{position: fixed; margin: 0; width: 100%; height: 100%; top: 0; left: 0; background: rgba(0,0,0,0.3);overflow: scroll; display: none;}
.overlay>div{margin: 3% 10%; background: #fff; padding: 1em;box-shadow: 0 0 3em #000; }
.overlay>div{margin: 3% 10%; background: #f8f8f8; padding: 1em;box-shadow: 0 0 3em #000; }
......@@ -16,6 +16,7 @@ require_once 'redirect.class.php';
* 2020-05-11 v1.4 ah rewrite as class
* 2022-02-03 v1.5 ah add method isEnabled
* 2022-05-23 v1.6 ah add http head check+render output;
* 2022-05-31 v1.7 ah optical changes
*/
/**
......@@ -31,7 +32,6 @@ class redirectadmin extends redirect {
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERAGENT => strip_tags($this->sAbout),
// CURLOPT_USERPWD => isset($this->aProfileEffective['userpwd']) ? $this->aProfileEffective['userpwd'] : false,
CURLOPT_VERBOSE => false,
CURLOPT_ENCODING => 'gzip, deflate', // to fetch encoding
CURLOPT_HTTPHEADER => array(
......@@ -43,10 +43,6 @@ class redirectadmin extends redirect {
// TODO: this is unsafe .. better: let the user configure it
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
// CURLOPT_SSL_VERIFYSTATUS => false,
// v0.22 cookies
CURLOPT_COOKIEJAR => $this->sCcookieFilename,
CURLOPT_COOKIEFILE => $this->sCcookieFilename,
CURLOPT_TIMEOUT => 5,
);
return $aReturn;
......@@ -102,7 +98,7 @@ class redirectadmin extends redirect {
$sReturn=($iHops>0
? 'Found hops: <strong>'.$iHops.'</strong>'
.($iHops>1 ? ' ⚠️ Verify your redirect to skip unneeded hops.' : '' ).'<br><br>'
.($iHops>1 ? ' <span class="warning"> ⚠️ Verify your redirect to skip unneeded hops.</span>' : '' ).'<br><br>'
: ''
).$sReturn
;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment