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

admin: show a welcome message after install

parent b70c0d24
No related branches found
No related tags found
1 merge request!2fix loop over config with missing regex section.
This commit is part of merge request !2. Comments created here will be created in the context of that merge request.
......@@ -13,6 +13,7 @@
* ----------------------------------------------------------------------
* 2022-02-03 v0.1 <axel.hahn@iml.unibe.ch> initial version
* 2022-05-31 v0.2 <axel.hahn@iml.unibe.ch> optical changes; use debugredirect=1 if url is a local domain
* 2023-08-28 v1.0 <axel.hahn@unibe.ch> Welcome message if there is no config yet
* ----------------------------------------------------------------------
*/
......@@ -37,6 +38,7 @@ $aIco=[
'type_alias'=>'◻️',
'url'=>'🌐',
'welcome'=>'🪄',
];
// ----------------------------------------------------------------------
......@@ -99,32 +101,7 @@ if (!$oR->isEnabled()){
// ---------- LOOP OVER ALL ENTRIES
$sHtml.='
<!--
<h2>'.$aIco['h2_head'].' Http head tester</h2>
<div class="content">
<form>
'.$aIco['url'].' <input type="text" name="url" size="100" value="'.$sUrl.'" placeholder="Enter url or click a link in the table below."/>
<button>Http HEAD</button>
</form>
</div>
<br>
-->
<h2>'.$aIco['h2_config'].' Domains and their redirects</h2>
<div class="content">
<table class="mydatatable"><thead>
<tr>
<th>Host</th>
<th>Ip address</th>
<th>Setup</th>
<th>Type</th>
<th>From</th>
<th>Code</th>
<th>Target</th>
</tr>
</thead><tbody>';
$sTable='';
foreach($aHosts as $sHost => $aCfg){
$sTdFirst='<tr class="cfgtype-'.$aCfg['type'].'">'
.'<td>'
......@@ -159,7 +136,7 @@ if (!$oR->isEnabled()){
if (count($aCfg['redirects'][$sType])){
foreach($aCfg['redirects'][$sType] as $sFrom=>$aTo){
$iCount++;
$sHtml.=$sTdFirst
$sTable.=$sTdFirst
.'<td class="type-'.$sType.'">'.$sType.'</td>'
.'<td class="type-'.$sType.'">'
.($sType == 'direct'
......@@ -177,28 +154,25 @@ if (!$oR->isEnabled()){
} else {
// type = alias
// $sHtml.='<tr>'.$sTdFirst.'<td></td><td></td><td></td><td>'.(isset($aCfg['target']) ? 'see config for <a href="#'.getId($aCfg['target']).'">'.$aCfg['target'].'</a>' : '').'</td></tr>';
$sHtml.=$sTdFirst.'<td></td><td></td><td></td><td>'.(isset($aCfg['target']) ? 'see config for <em>'.$aCfg['target'].'</em>' : '').'</td></tr>';
$sTable.=$sTdFirst.'<td></td><td></td><td></td><td>'.(isset($aCfg['target']) ? 'see config for <em>'.$aCfg['target'].'</em>' : '').'</td></tr>';
}
}
$sHtml.='</tbody></table></div>'
/*
.'<h2>Config array</h2>
<pre>'.print_r($aHosts, 1).'</pre>'
*/
;
$sErrors = $sErrors
? '<h2>'.$aIco['h2_err'].' Found errors</h2>'
.'<div class="content">'
.'<ol class="error">'
.$sErrors
.'</ol>'
.'</div>'
: ''
;
$sTable='';
$sHtml.=''
$sTable=$sTable
? '<table class="mydatatable"><thead>
<tr>
<th>Host</th>
<th>Ip address</th>
<th>Setup</th>
<th>Type</th>
<th>From</th>
<th>Code</th>
<th>Target</th>
</tr>
</thead><tbody>'.$sTable.'</tbody></table></div>'
. '<br><br>'
.'<div class="content legend">'
. '<strong>Legend</strong>:<br>'
......@@ -230,7 +204,54 @@ if (!$oR->isEnabled()){
.'</tbody></table>'
.'</div>'
.'<footer><a href="'.$oR->urlRepo.'">Source</a> | <a href="'.$oR->urlDocs.'">Docs</a></footer>'
: '<h3>'.$aIco['welcome'].' Welcome!</h3>
<p>
Thank you for the installation!<br>
Now is a good moment to create your first config.
</p>
<ul>
<li>Go to the directory ./config/</li>
<li>Watch the *.dist files - make a copy of them to *.json (without .dist)</li>
<li>Relaod this page</li>
</ul>
<p>
See the <a href="'.$oR->urlDocs.'Configuration.html" target="_blank">Docs</a> for details.
</p>
'
;
$sHtml.='
<!--
<h2>'.$aIco['h2_head'].' Http head tester</h2>
<div class="content">
<form>
'.$aIco['url'].' <input type="text" name="url" size="100" value="'.$sUrl.'" placeholder="Enter url or click a link in the table below."/>
<button>Http HEAD</button>
</form>
</div>
<br>
-->
<h2>'.$aIco['h2_config'].' Domains and their redirects</h2>
<div class="content">'
/*
.'<h2>Config array</h2>
<pre>'.print_r($aHosts, 1).'</pre>'
*/
.$sTable
;
$sErrors = $sErrors
? '<h2>'.$aIco['h2_err'].' Found errors</h2>'
.'<div class="content">'
.'<ol class="error">'
.$sErrors
.'</ol>'
.'</div>'
: ''
;
$sHtml.='<footer><a href="'.$oR->urlRepo.'">Source</a> | <a href="'.$oR->urlDocs.'">Docs</a></footer>'
;
}
......
......@@ -3,6 +3,7 @@ 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: #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; margin: 0 0 1em;}
h3{color:#ccc; font-size: 250%}
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);}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment