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
Branches
No related tags found
1 merge request!2fix loop over config with missing regex section.
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
* ---------------------------------------------------------------------- * ----------------------------------------------------------------------
* 2022-02-03 v0.1 <axel.hahn@iml.unibe.ch> initial version * 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 * 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=[ ...@@ -37,6 +38,7 @@ $aIco=[
'type_alias'=>'◻️', 'type_alias'=>'◻️',
'url'=>'🌐', 'url'=>'🌐',
'welcome'=>'🪄',
]; ];
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
...@@ -99,32 +101,7 @@ if (!$oR->isEnabled()){ ...@@ -99,32 +101,7 @@ if (!$oR->isEnabled()){
// ---------- LOOP OVER ALL ENTRIES // ---------- LOOP OVER ALL ENTRIES
$sTable='';
$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>';
foreach($aHosts as $sHost => $aCfg){ foreach($aHosts as $sHost => $aCfg){
$sTdFirst='<tr class="cfgtype-'.$aCfg['type'].'">' $sTdFirst='<tr class="cfgtype-'.$aCfg['type'].'">'
.'<td>' .'<td>'
...@@ -159,7 +136,7 @@ if (!$oR->isEnabled()){ ...@@ -159,7 +136,7 @@ if (!$oR->isEnabled()){
if (count($aCfg['redirects'][$sType])){ if (count($aCfg['redirects'][$sType])){
foreach($aCfg['redirects'][$sType] as $sFrom=>$aTo){ foreach($aCfg['redirects'][$sType] as $sFrom=>$aTo){
$iCount++; $iCount++;
$sHtml.=$sTdFirst $sTable.=$sTdFirst
.'<td class="type-'.$sType.'">'.$sType.'</td>' .'<td class="type-'.$sType.'">'.$sType.'</td>'
.'<td class="type-'.$sType.'">' .'<td class="type-'.$sType.'">'
.($sType == 'direct' .($sType == 'direct'
...@@ -177,28 +154,25 @@ if (!$oR->isEnabled()){ ...@@ -177,28 +154,25 @@ if (!$oR->isEnabled()){
} else { } else {
// type = alias // 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.='<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 $sTable='';
? '<h2>'.$aIco['h2_err'].' Found errors</h2>'
.'<div class="content">'
.'<ol class="error">'
.$sErrors
.'</ol>'
.'</div>'
: ''
;
$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>' . '<br><br>'
.'<div class="content legend">' .'<div class="content legend">'
. '<strong>Legend</strong>:<br>' . '<strong>Legend</strong>:<br>'
...@@ -230,7 +204,54 @@ if (!$oR->isEnabled()){ ...@@ -230,7 +204,54 @@ if (!$oR->isEnabled()){
.'</tbody></table>' .'</tbody></table>'
.'</div>' .'</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;} ...@@ -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{background:rgba(0,0,0,0.05); margin: 0 0 1em;; padding: 0.5em;}
h1 a{color:#234; text-decoration: none;} 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;} 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);} 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