3

I have a simple web page with some jQuery ajax and PHP backside to easily view the error_log quickly and erase it for debugging and development purposes.

However, I noticed in FireFox that I have a mixed-content warning. I checked on Chrome and it gave the error.

Mixed Content: The page at 'https://website/error_log.php' was loaded over HTTPS, but requested an insecure favicon 'http://website/content.php?error=404'. This request has been blocked; the content must be served over HTTPS.

This would be simpel to me as I would just have to find the Favicon and specify the correct path to it (since it's obviously not found and throwing it to the 404 page) using https. However, I do not have a favicon specified on my page at all, so why is it giving me the mixed content notice?

Error Log

<?php
if(@$_GET["unlink"]=="yes") {
    if(file_exists('error_log')) {
        unlink('error_log');
    }
    exit(0);
}
if(@$_GET["ajax"]=="yes") {
    if(file_exists('error_log')) {
        //$file = file_get_contents('error_log');
        $fileLines = file('error_log');
        // Swap the order of the array
        $invertedLines = array_reverse($fileLines);
        echo '<pre>';
        //echo $file;
        for($i=0;$i<count($invertedLines);$i++) {
            echo $invertedLines[$i];
        }
        echo '</pre>';
    }
    else {
        echo '<pre>';
        echo '<div align="center">The error log is currently empty.</div>';
        echo '</pre>';
    }
    exit(0);
}
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Error Log</title>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function() {
    var interval;
    interval = setInterval(counter, 1000);
    $("#refresh").click(function(){
        refreshlog();
        clearInterval(interval);
        $('#refresh').val("Refreshed...");
        interval = setInterval(counter, 1000);  
    }); 
    $("#delete").click(function(){
        unlink();
    }); 

    
    var count = 30; 
    function counter() {
        if(count===30) {
            refreshlog();
        }
        count--;
        //console.log(count);
        $('#refresh').val('Refresh Error Log ('+count+')');
        if (count === 0) {
            count = 30;
        }
    }
    function refreshlog() {
        $.ajax({url: "./error_log.php?ajax=yes", success: function(result){
            $("#div1").html(result);
        }});
    }
    function unlink() {
        $.ajax({url: "./error_log.php?unlink=yes", success: function(result){
            refreshlog();
        }});
    }
    
});
</script>
<style>
pre
{
  font-family: Consolas, Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif;
  margin-bottom: 10px;
  overflow: auto;
  width: auto;
  padding: 5px;
  background-color: #eee;
  width: 650px!ie7;
  padding-bottom: 20px!ie7;
  max-height: 500px;
}
</style>
</head>
<body>
<div align="center"><input type="button" id='refresh' style="border: 1px solid #050; color: #050; padding: 5px; margin: 3px; cursor: pointer;" value="Refresh Error Log"><input type="button"id='delete' style="border: 1px solid #C00; color: #c00; padding: 5px; margin: 3px; cursor: pointer;" value="Clear Error Log"></div>
<hr>
<div id='div1'></div>
<hr>
</body></html>
Dawson Irvine
  • 322
  • 4
  • 19
  • 2
    Some browsers automatically request `/favicon.ico`, if no other favicon URL was explicitly specified. Here in your instance, that request appears to have been _redirected to_ `http://website/content.php?error=404` - which indicates your setup of the 404 error document is wrong. (It should not be using HTTP, but even more importantly, it should not redirect externally in the first place.) – CBroe Dec 11 '20 at 08:28
  • @CBroe I was not aware of this! Is there any way to tell where the browser is looking for the favicon? Also, I assume the 404 setup is that it shouldn't be directing to a specific URL and instead be local `ErrorDocument /content.php?error=404`, correct? – Dawson Irvine Dec 11 '20 at 16:44
  • 1
    Where, `/favicon.ico` directly under the domain root. And yes, a relative URL should be used for ErrorDocument. – CBroe Dec 14 '20 at 07:33

0 Answers0