diff --git a/public_html/admin/index.php b/public_html/admin/index.php index 691e8de24d8e7459ff1e2a6d550a0113f2aa2139..edd4138432c06cb65f413f90935400d2a2a13f82 100644 --- a/public_html/admin/index.php +++ b/public_html/admin/index.php @@ -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 () { diff --git a/public_html/classes/redirect.admin.class.php b/public_html/classes/redirect.admin.class.php index ee838b424a003d1e78dc0e5ddb04aef62415bd5b..190a8a7f87c4dcb15260bc6ca6cdc4857df2db4e 100644 --- a/public_html/classes/redirect.admin.class.php +++ b/public_html/classes/redirect.admin.class.php @@ -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;