[Gelöst] Komisches Verhalten mit header Location bei PHP7.3

Heute ist Stammtischzeit:
Jeden Donnerstag 20:30 Uhr hier im Chat.
Wer Lust hat, kann sich gerne beteiligen. ;)
  • Moin, ich habe meinem Pi2 eine neue SD gegönnt und natürlich erst mal das neueste Image draufgespielt, alle Updates ...

    Jetzt das merkwürdige, ich habe eine index.php mit dem Inhalt:

    Code
    <a href="../strom_an.php"><img src="../licht_an.jpg" width="400" height="400"></img></a>
    <a href="../strom_aus.php"><img src="../licht_aus.jpg" width="400" height="400"></img></a>

    und 2 Dateien, strom_an.php und strom_aus.php

    PHP
    <?php
    shell_exec ('sudo /var/www/html/pins/5an.sh');
    header('Location:index.php');
    exit;
    ?>
    PHP
    <?php
    shell_exec ('sudo /var/www/html/pins/5aus.sh');
    header('Location:index.php');
    exit;
    ?>

    Als noch Stretch mit PHP7.0 drauf war, hat das wunderbar geklappt, jetzt mit Buster und PHP7.3 bekomme ich eine weiße Seite, er hängt bei strom_an.php und leitet mich nicht mehr weiter auf die index.php. Wenn ich auf Licht aus klicke, leitet er mich brav wieder auf die index.php. Das witzige ist, dass es mit meinem Android-Smartphone geht, auch mit w3m, jedoch nicht mit Firefox an meinem Netbook mit Win10. :-/ :denker: :conf:

    In den Logs steht nichts besonderes drin, die Dateien gehören alle www-data, ich weiss nicht mehr weiter. :helpnew:

    Woran könnte das liegen ?

  • [Gelöst] Komisches Verhalten mit header Location bei PHP7.3? Schau mal ob du hier fündig wirst!

  • Also bei an hängt der fest, aber bei aus funktionierts? :conf:

    Genau, das ist ja das merkwürdige, mit w3m sehe ich zwar keine Bilder, aber beim klicken auf den Link gehts, auch mit dem Smartphone mit Bildklick.

    Aber mit dem Netbook mit Win10 wills nicht mehr angehen, nur noch aus.

    Btw. www-data und sudo ist nicht gut. besser www-data in die Gruppe gpio, wenns nur im Heimnetz ist!

    Ich weiss. ;)

    • Offizieller Beitrag

    Wirklich komisch!

    Aber was warum läufts mit aus, aber nicht mit an? Was unterscheidet beide Skripte, ausser den Befehlen für an und aus natürlich? Haben beide Ausgaben und falls ja, könntest Du die mit nach /dev/null umleiten mal testen?

  • Also aus den access-Logs mit Firefox index.php aufgerufen und auf licht_an geklickt:

    Code
    192.168.0.101 - - [13/Sep/2020:13:11:21 +0200] "GET / HTTP/1.1" 200 824 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0"

    Scheint nicht anzukommen.

    Das gleiche mit licht_aus:

    Code
    192.168.0.101 - - [13/Sep/2020:13:16:29 +0200] "GET /strom_aus.php HTTP/1.1" 302 228 "http://192.168.0.31/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0"
    192.168.0.101 - - [13/Sep/2020:13:16:31 +0200] "GET /index.php HTTP/1.1" 200 824 "http://192.168.0.31/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0"

    Mit Chrome index.php und licht an:

    Code
    92.168.0.101 - - [13/Sep/2020:13:18:24 +0200] "GET / HTTP/1.1" 200 823 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safar$
    192.168.0.101 - - [13/Sep/2020:13:18:30 +0200] "GET /strom_an.php HTTP/1.1" 302 228 "http://192.168.0.31/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Ge$
    192.168.0.101 - - [13/Sep/2020:13:18:31 +0200] "GET /index.php HTTP/1.1" 200 823 "http://192.168.0.31/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko$

    Scheint anzukommen. :denker:

    Mit dem Smartphone Chrome auf index.php und licht_an:

    Code
    192.168.0.115 - - [13/Sep/2020:13:20:52 +0200] "GET /strom_an.php HTTP/1.1" 302 229 "http://192.168.0.31/index.php" "Mozilla/5.0 (Linux; Android 10; Nokia 2.1) AppleWebKit/537.36 (KHTM$
    192.168.0.115 - - [13/Sep/2020:13:20:54 +0200] "GET /index.php HTTP/1.1" 200 823 "http://192.168.0.31/index.php" "Mozilla/5.0 (Linux; Android 10; Nokia 2.1) AppleWebKit/537.36 (KHTML, $

    Mit Firefox aufm Smartphone kann ich gerade nicht testen, weil Firefox nach Update auf Android 10 nicht mehr geht.

    Ausgaben gibts keine.

  • Mir ist so ein Verhalten mit gif Bildern aufgefallen mit verschiedenen Browsern auf android, da muss mal den cache der App löschen und schon wird das richtige gif angzeigt. Kann es sein das <Alt> <F5> hilft (<Strg> <F5>) Browser Cache von Firefox löschen. Ich denk eher nicht, will es nur schreiben.

  • Alles leer, ausser bei Konsole:

    Zitat

    Die Zeichenkodierung des HTML-Dokuments wurde nicht deklariert. Das Dokument wird in manchen Browser-Konfigurationen mit verstümmeltem Text dargestellt, wenn das Dokument Zeichen außerhalb des US-ASCII-Bereichs enthält. Die Zeichenkodierung der Seite muss im Dokument oder Transferprotokoll deklariert werden. strom_an.php

    Source-Map-Fehler: Error: NetworkError when attempting to fetch resource.

    Ressourcen-Adresse: moz-extension://bd353349-c40b-476c-a580-245eb99f3ec9/content/js/purify.min.js

    Source-Map-Adresse: purify.min.js.map

  • Ah, nochmal aktualisieren, dann kommt was, aber für mich nichts hilfreiches.

    Spoiler anzeigen

    (function injected(eventName, injectedIntoContentWindow)

    {

    let checkRequest;

    /*

    * Frame context wrapper

    *

    * For some edge-cases Chrome will not run content scripts inside of frames.

    * Website have started to abuse this fact to access unwrapped APIs via a

    * frame's contentWindow (#4586, 5207). Therefore until Chrome runs content

    * scripts consistently for all frames we must take care to (re)inject our

    * wrappers when the contentWindow is accessed.

    */

    let injectedToString = Function.prototype.toString.bind(injected);

    let injectedFrames = new WeakSet();

    let injectedFramesAdd = WeakSet.prototype.add.bind(injectedFrames);

    let injectedFramesHas = WeakSet.prototype.has.bind(injectedFrames);

    function injectIntoContentWindow(contentWindow)

    {

    if (contentWindow && !injectedFramesHas(contentWindow))

    {

    injectedFramesAdd(contentWindow);

    try

    {

    contentWindow[eventName] = checkRequest;

    contentWindow.eval(

    "(" + injectedToString() + ")('" + eventName + "', true);"

    );

    delete contentWindow[eventName];

    }

    catch (e) {}

    }

    }

    for (let element of [HTMLFrameElement, HTMLIFrameElement, HTMLObjectElement])

    {

    let contentDocumentDesc = Object.getOwnPropertyDescriptor(

    element.prototype, "contentDocument"

    );

    let contentWindowDesc = Object.getOwnPropertyDescriptor(

    element.prototype, "contentWindow"

    );

    // Apparently in HTMLObjectElement.prototype.contentWindow does not exist

    // in older versions of Chrome such as 51.

    if (!contentWindowDesc)

    continue;

    let getContentDocument = Function.prototype.call.bind(

    contentDocumentDesc.get

    );

    let getContentWindow = Function.prototype.call.bind(

    contentWindowDesc.get

    );

    contentWindowDesc.get = function()

    {

    let contentWindow = getContentWindow(this);

    injectIntoContentWindow(contentWindow);

    return contentWindow;

    };

    contentDocumentDesc.get = function()

    {

    injectIntoContentWindow(getContentWindow(this));

    return getContentDocument(this);

    };

    Object.defineProperty(element.prototype, "contentWindow",

    contentWindowDesc);

    Object.defineProperty(element.prototype, "contentDocument",

    contentDocumentDesc);

    }

    /*

    * RTCPeerConnection wrapper

    *

    * The webRequest API in Chrome does not yet allow the blocking of

    * WebRTC connections.

    * See https://bugs.chromium.org/p/chromium/issues/detail?id=707683

    */

    let RealCustomEvent = window.CustomEvent;

    // If we've been injected into a frame via contentWindow then we can simply

    // grab the copy of checkRequest left for us by the parent document. Otherwise

    // we need to set it up now, along with the event handling functions.

    if (injectedIntoContentWindow)

    {

    checkRequest = window[eventName];

    }

    else

    {

    let addEventListener = document.addEventListener.bind(document);

    let dispatchEvent = document.dispatchEvent.bind(document);

    let removeEventListener = document.removeEventListener.bind(document);

    checkRequest = (url, callback) =>

    {

    let incomingEventName = eventName + "-" + url;

    function listener(event)

    {

    callback(event.detail);

    removeEventListener(incomingEventName, listener);

    }

    addEventListener(incomingEventName, listener);

    dispatchEvent(new RealCustomEvent(eventName, {detail: {url}}));

    };

    }

    // Only to be called before the page's code, not hardened.

    function copyProperties(src, dest, properties)

    {

    for (let name of properties)

    {

    if (Object.prototype.hasOwnProperty.call(src, name))

    {

    Object.defineProperty(dest, name,

    Object.getOwnPropertyDescriptor(src, name));

    }

    }

    }

    let RealRTCPeerConnection = window.RTCPeerConnection ||

    window.webkitRTCPeerConnection;

    // Firefox has the option (media.peerconnection.enabled) to disable WebRTC

    // in which case RealRTCPeerConnection is undefined.

    if (typeof RealRTCPeerConnection != "undefined")

    {

    let closeRTCPeerConnection = Function.prototype.call.bind(

    RealRTCPeerConnection.prototype.close

    );

    let RealArray = Array;

    let RealString = String;

    let {create: createObject, defineProperty} = Object;

    let normalizeUrl = url =>

    {

    if (typeof url != "undefined")

    return RealString(url);

    };

    let safeCopyArray = (originalArray, transform) =>

    {

    if (originalArray == null || typeof originalArray != "object")

    return originalArray;

    let safeArray = RealArray(originalArray.length);

    for (let i = 0; i < safeArray.length; i++)

    {

    defineProperty(safeArray, i, {

    configurable: false, enumerable: false, writable: false,

    value: transform(originalArray[i])

    });

    }

    defineProperty(safeArray, "length", {

    configurable: false, enumerable: false, writable: false,

    value: safeArray.length

    });

    return safeArray;

    };

    // It would be much easier to use the .getConfiguration method to obtain

    // the normalized and safe configuration from the RTCPeerConnection

    // instance. Unfortunately its not implemented as of Chrome unstable 59.

    // See https://www.chromestatus.com/feature/5271355306016768

    let protectConfiguration = configuration =>

    {

    if (configuration == null || typeof configuration != "object")

    return configuration;

    let iceServers = safeCopyArray(

    configuration.iceServers,

    iceServer =>

    {

    let {url, urls} = iceServer;

    // RTCPeerConnection doesn't iterate through pseudo Arrays of urls.

    if (typeof urls != "undefined" && !(urls instanceof RealArray))

    urls = [urls];

    return createObject(iceServer, {

    url: {

    configurable: false, enumerable: false, writable: false,

    value: normalizeUrl(url)

    },

    urls: {

    configurable: false, enumerable: false, writable: false,

    value: safeCopyArray(urls, normalizeUrl)

    }

    });

    }

    );

    return createObject(configuration, {

    iceServers: {

    configurable: false, enumerable: false, writable: false,

    value: iceServers

    }

    });

    };

    let checkUrl = (peerconnection, url) =>

    {

    checkRequest(url, blocked =>

    {

    if (blocked)

    {

    // Calling .close() throws if already closed.

    try

    {

    closeRTCPeerConnection(peerconnection);

    }

    catch (e) {}

    }

    });

    };

    let checkConfiguration = (peerconnection, configuration) =>

    {

    if (configuration && configuration.iceServers)

    {

    for (let i = 0; i < configuration.iceServers.length; i++)

    {

    let iceServer = configuration.iceServers[i];

    if (iceServer)

    {

    if (iceServer.url)

    checkUrl(peerconnection, iceServer.url);

    if (iceServer.urls)

    {

    for (let j = 0; j < iceServer.urls.length; j++)

    checkUrl(peerconnection, iceServer.urls[j]);

    }

    }

    }

    }

    };

    // Chrome unstable (tested with 59) has already implemented

    // setConfiguration, so we need to wrap that if it exists too.

    // https://www.chromestatus.com/feature/5596193748942848

    if (RealRTCPeerConnection.prototype.setConfiguration)

    {

    let realSetConfiguration = Function.prototype.call.bind(

    RealRTCPeerConnection.prototype.setConfiguration

    );

    RealRTCPeerConnection.prototype.setConfiguration = function(configuration)

    {

    configuration = protectConfiguration(configuration);

    // Call the real method first, so that validates the configuration for

    // us. Also we might as well since checkRequest is asynchronous anyway.

    realSetConfiguration(this, configuration);

    checkConfiguration(this, configuration);

    };

    }

    let WrappedRTCPeerConnection = function(...args)

    {

    if (!(this instanceof WrappedRTCPeerConnection))

    return RealRTCPeerConnection();

    let configuration = protectConfiguration(args[0]);

    // Since the old webkitRTCPeerConnection constructor takes an optional

    // second argument we need to take care to pass that through. Necessary

    // for older versions of Chrome such as 51.

    let constraints;

    if (args.length > 1)

    constraints = args[1];

    let peerconnection = new RealRTCPeerConnection(configuration,

    constraints);

    checkConfiguration(peerconnection, configuration);

    return peerconnection;

    };

    WrappedRTCPeerConnection.prototype = RealRTCPeerConnection.prototype;

    let boundWrappedRTCPeerConnection = WrappedRTCPeerConnection.bind();

    copyProperties(RealRTCPeerConnection, boundWrappedRTCPeerConnection,

    ["generateCertificate", "name", "prototype"]);

    RealRTCPeerConnection.prototype.constructor = boundWrappedRTCPeerConnection;

    if ("RTCPeerConnection" in window)

    window.RTCPeerConnection = boundWrappedRTCPeerConnection;

    if ("webkitRTCPeerConnection" in window)

    window.webkitRTCPeerConnection = boundWrappedRTCPeerConnection;

    }

    })('abp-request-l1ogph2o8s');

    Ich gebe es auf und setze auf "Gelöst", es liegt an Firefox. :auslachen::baeh2:

    Danke für die Hilfe :danke_ATDE::bravo2:

    • Offizieller Beitrag

    Aber was warum läufts mit aus, aber nicht mit an? Was unterscheidet beide Skripte, ausser den Befehlen für an und aus natürlich?

    Btw. Funktioniert ein meta refresh? Mir ist klar, dass man das nicht mehr machen sollte, aber Versuch macht klug.

    PHP
    echo "<html>
    <head>
    <title>Weiterleitung</title>
    <meta http-equiv=\"refresh\" content=\"2; URL=index.php\">
    </head>
    <body>
    <p>Weiterleitung zum <a href=\"index.php\">Index</a></p>
    </body>
    </html>";

    //Edit: Arrr.. Ist ja PHP, dann kann man den HTML-Teil auch in Klartext schreiben.

Jetzt mitmachen!

Du hast noch kein Benutzerkonto auf unserer Seite? Registriere dich kostenlos und nimm an unserer Community teil!