Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
redirect-handler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
redirect-handler
Commits
a327bdbc
Commit
a327bdbc
authored
3 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
update admin: show more hints and warnings
parent
1d616014
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
public_html/admin/index.php
+25
-12
25 additions, 12 deletions
public_html/admin/index.php
public_html/classes/redirect.admin.class.php
+12
-0
12 additions, 0 deletions
public_html/classes/redirect.admin.class.php
with
37 additions
and
12 deletions
public_html/admin/index.php
+
25
−
12
View file @
a327bdbc
...
...
@@ -18,6 +18,7 @@
require_once
'../classes/redirect.admin.class.php'
;
$oR
=
new
redirectadmin
();
$sHtml
=
''
;
$sErrors
=
''
;
// ----------------------------------------------------------------------
// FUNCTIONS
...
...
@@ -44,18 +45,13 @@ if (!$oR->isEnabled()){
// ---------- SHOW ERRORS
if
(
count
(
$aHosts
[
'_errors'
]))
{
$sHtml
.
=
'<h2>🔔 Found errors</h2>'
.
'<div class="content">'
.
'<ol class="error">'
.
'<li>'
.
implode
(
'</li></li>'
,
$aHosts
[
'_errors'
])
.
'</li>'
.
'</ol>'
.
'</div>'
;
$sErrors
.
=
'<li>'
.
implode
(
'</li></li>'
,
$aHosts
[
'_errors'
])
.
'</li>'
;
}
unset
(
$aHosts
[
'_errors'
]);
// ---------- LOOP OVER ALL ENTRIES
$sMyIp
=
gethostbyname
(
gethostname
());
$sHtml
.
=
'
<h2>✔️ Http head tester</h2>
<div class="content">
...
...
@@ -82,12 +78,20 @@ if (!$oR->isEnabled()){
</thead><tbody>'
;
foreach
(
$aHosts
as
$sHost
=>
$aCfg
){
$sTdFirst
=
'<tr class="cfgtype-'
.
$aCfg
[
'type'
]
.
'">'
.
'<td>🔷 <a href="?url=http://'
.
$sHost
.
'/">'
.
$sHost
.
'</a></td>'
.
'<td>🔷 <a href="?url=http://'
.
$sHost
.
'/"
title="click to test http://'
.
$sHost
.
'/"
>'
.
$sHost
.
'</a></td>'
.
'<td>'
.
(
$aCfg
[
'ip'
]
?
$aCfg
[
'ip'
]
:
'<span class="error">ERROR: unknown host</span>'
)
.
(
$aCfg
[
'ip'
]
?
(
$aCfg
[
'ip'
]
===
$sMyIp
?
'<span title="">🟢 '
.
$aCfg
[
'ip'
]
.
'</span>'
:
'<span title="Warning: this is not the ip address of the current host ('
.
$sMyIp
.
')">🟠 '
.
$aCfg
[
'ip'
]
.
'</span>'
)
:
'<span class="error">❗ERROR: unknown host</span>'
)
.
'</td>'
.
'<td>'
.
$aCfg
[
'type'
]
.
'</td>'
;
if
(
!
$aCfg
[
'ip'
]){
$sErrors
.
=
'<li>Host was not found in DNS: '
.
$sHost
.
'</li>'
;
}
if
(
isset
(
$aCfg
[
'redirects'
])){
$iCount
=
0
;
foreach
([
'direct'
,
'regex'
]
as
$sType
){
...
...
@@ -97,10 +101,10 @@ if (!$oR->isEnabled()){
$sHtml
.
=
$sTdFirst
.
'<td class="type-'
.
$sType
.
'">'
.
$sType
.
'</td>'
.
'<td class="type-'
.
$sType
.
'">'
.
(
$sType
==
'direct'
?
'<a href="?url=http://'
.
$sHost
.
'/'
.
$sFrom
.
'">'
.
$sFrom
.
'</a>'
:
$sFrom
)
.
(
$sType
==
'direct'
?
'<a href="?url=http://'
.
$sHost
.
'/'
.
$sFrom
.
'"
title="click to test http://'
.
$sHost
.
'/'
.
$sFrom
.
'"
>'
.
$sFrom
.
'</a>'
:
$sFrom
)
.
'</td>'
.
'<td class="http-'
.
$aTo
[
'code'
]
.
'">'
.
$aTo
[
'code'
]
.
'</td>'
.
'<td>🌐 <a href="?url='
.
$aTo
[
'target'
]
.
'">'
.
$aTo
[
'target'
]
.
'</a></td>'
.
'<td>🌐 <a href="?url='
.
$aTo
[
'target'
]
.
'"
title="click to test '
.
$aTo
[
'target'
]
.
'"
>'
.
$aTo
[
'target'
]
.
'</a></td>'
.
'</tr>'
;
}
}
...
...
@@ -130,6 +134,15 @@ if (!$oR->isEnabled()){
;
}
$sErrors
=
$sErrors
?
'<h2>🔔 Found errors</h2>'
.
'<div class="content">'
.
'<ol class="error">'
.
$sErrors
.
'</ol>'
.
'</div>'
:
''
;
}
...
...
@@ -147,7 +160,7 @@ if (!$oR->isEnabled()){
<body>
<h1>
⏩
<a
href=
"?"
>
Redirects :: admin
</a></h1>
<?php
echo
$sHtml
;
?>
<?php
echo
$sErrors
.
$sHtml
;
?>
<script>
$
(
document
).
ready
(
function
()
{
...
...
This diff is collapsed.
Click to expand it.
public_html/classes/redirect.admin.class.php
+
12
−
0
View file @
a327bdbc
...
...
@@ -85,6 +85,7 @@ class redirectadmin extends redirect {
.
'</pre>'
;
}
else
{
$sReturn
=
preg_replace
(
'/(HTTP.*)\\r/'
,
'</pre><pre><strong>$1</strong>'
,
$sReturn
);
$sReturn
=
preg_replace
(
'/(HTTP.*200.*)/'
,
'<span class="status status-ok">$1</span>'
,
$sReturn
);
$sReturn
=
preg_replace
(
'/(HTTP.*30.*)/'
,
'<span class="status status-redirect">$1</span>'
,
$sReturn
);
...
...
@@ -93,6 +94,17 @@ class redirectadmin extends redirect {
$sReturn
=
preg_replace
(
'/(x-debug-.*)\\r/i'
,
'<span class="debug">$1</span>'
,
$sReturn
);
$sReturn
=
preg_replace
(
'/(location:.*)\\r/i'
,
'<span class="location">$1</span>'
,
$sReturn
);
$sReturn
.
=
'</pre>'
;
preg_match_all
(
'/(HTTP\/.*)/i'
,
$sReturn
,
$aTmp
);
// $sReturn.=print_r($aTmp, 1);
$iHops
=
(
count
(
$aTmp
[
0
])
-
1
);
$sReturn
=
(
$iHops
>
0
?
'Found hops: <strong>'
.
$iHops
.
'</strong>'
.
(
$iHops
>
1
?
' ⚠️ Verify your redirect to skip unneeded hops.'
:
''
)
.
'<br><br>'
:
''
)
.
$sReturn
;
}
return
$sReturn
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment