Originale Fehlerseite wirft Status 400 aus anstelle 404

Fragen zur Installation von CONTENIDO 4.10? Probleme bei der Konfiguration? Hinweise oder Fragen zur Entwicklung des Systemes oder zur Sicherheit?
Antworten
peanut
Beiträge: 246
Registriert: Do 25. Nov 2004, 19:34
Kontaktdaten:

Originale Fehlerseite wirft Status 400 aus anstelle 404

Beitrag von peanut » Do 15. Dez 2022, 10:25

Mir ist eben aufgefallen, das die originale Fehlerseite - fehlerseite.html?error=1 einen Status 400 auswirft. Ich habe das mit AtomSeo geprüft und gehe mal davon aus das die wissen was sie machen :-)

Geht um die 4.10.1

Weiss dazu jemand eventuell was aktuelles ? Es gibt dazu uralte Einträge von daher frage ich vorsichtshalber mal nach. Ist ja auch ein Bug irgendwie. Unten hab ich zwar die Lösung von der KI aber weiss nicht wo der PHP Code genau hin muss bzw. was ersetzt werden muss.

Vielen Dank im Voraus
Gruss
Peanut
+++++++++ Anmerkung
Diese Filenamen sind nur ein Beispiel ... Welche .php Files genau man ändern muss bleibt offen




Der Chat Bot sagt dazu folgendes:

Meine Frage: how do i change a status code from 400 into 404 ?

To change a status code from 400 to 404, you would need to modify the code of the website or web application that is generating the status code. This typically involves using a programming language like JavaScript or PHP to access the server-side code and change the status code that is being sent in the HTTP response.

For example, if the website or web application is using JavaScript, you could use the following code to change the status code from 400 to 404:

Code: Alles auswählen

// Get the HTTP response object
var response = http.ServerResponse;

Code: Alles auswählen

// Set the status code to 404
response.statusCode = 404;
Similarly, if the website or web application is using PHP, you could use the following code to change the status code from 400 to 404:

Code: Alles auswählen

// Get the HTTP response object
$response = http_response_code();

Code: Alles auswählen

// Set the status code to 404
http_response_code(404);

UND JETZT WIRDS SPOOKY LEUTE
############################


Meine nächste Frage an den Chat Bot:

do you know where to add the php code of the 400 to 404 into the CMS called contenido ?

To add PHP code to change the status code from 400 to 404 in the CMS called Contenido, you would need to modify the PHP files that are responsible for generating the HTTP response. The exact steps for doing this will depend on the specific configuration and setup of your Contenido installation, but here are some general guidelines that you can follow:

Locate the PHP files that are used to generate the HTTP response for the page or pages where you want to change the status code. In Contenido, these files are typically located in the /contenido/includes directory.

Open the PHP files in a text editor or code editor, and search for the code that sets the HTTP status code. This code will typically be in the form of a call to the http_response_code() function.

Modify the code that sets the HTTP status code to change the status code from 400 to 404. To do this, you can use the following code:

Code: Alles auswählen

// Set the status code to 404
http_response_code(404);

Save the PHP files and upload them to your web server to apply the changes.

Test the changes by accessing the page or pages where you added the code, and verify that the HTTP status code is now 404 instead of 400.

It is important to note that modifying the PHP code of your Contenido installation can be risky, and you should exercise caution when making changes. Be sure to back up your files and database before making any changes, and test the changes thoroughly before deploying them to a production environment. If you are not comfortable modifying the PHP code of your Contenido installation, you should consider seeking the assistance of a qualified developer or consultant.


Meine nächste Frage:

which file in /contenido/includes do i have to modify for this changing ?

To change the HTTP status code from 400 to 404 in Contenido, you would need to modify the PHP files that are responsible for generating the HTTP response. The exact PHP files that you need to modify will depend on the specific configuration and setup of your Contenido installation, but some common files that you might need to modify include:

front_content.php: This file is responsible for generating the main content of a page in Contenido. It is typically called by the main Contenido frontend script (front_content.php) to generate the content of a page.

front_content_includes.php: This file is responsible for including other PHP files that are needed to generate the content of a page in Contenido. It is typically called by the main Contenido frontend script (front_content.php) to include the necessary files for generating the content of a page.

front_content_model.php: This file is responsible for defining the model (or structure) of a page in Contenido. It is typically called by the main Contenido frontend script (front_content.php) to define the model of a page.

front_content_render.php: This file is responsible for rendering the content of a page in Contenido. It is typically called by the main Contenido frontend script (front_content.php) to render the content of a page.

You should be able to find these files in the /contenido/includes directory of your Contenido installation. Once you have located the relevant PHP files, you can modify them as described in the previous answer to change the HTTP status code from 400 to 404.





Und zu guter Letzt habe ich nach einem Beispiel gefragt

Here is an example of what the front_content.php file might look like, with the necessary changes to change the HTTP status code from 400 to 404:

Code: Alles auswählen

<?php

// Include the necessary PHP files
include_once("front_content_includes.php");
include_once("front_content_model.php");
include_logic("front_content_logic.php");

// Set the HTTP status code to 404
http_response_code(404);

// Generate the content of the page
front_content_render($idcat, $idart, $template_name);

?>

In this code, the http_response_code() function is called with the argument 404 to change the HTTP status code from 400 to 404. This code should be added to the front_content.php file in the /contenido/includes directory of your Contenido installation.

ist ja unfassbar oder ? Jetzt hat doch echt die K.i mein nächstes Problem gelöst. Sogar über Contenido weiss es alles wie es scheint.

https://chat.openai.com/chat

Ich kanns nur jedem empfehlen ... War wieder schön mit sich selbst zu reden :-)


+++++++++ Anmerkung
Diese Files sind nur ein Beispiel ... Welche .php genau man ändern muss bleibt offen
Zuletzt geändert von peanut am Do 15. Dez 2022, 13:06, insgesamt 1-mal geändert.
du liest nie ein Buch und weisst weise der Bildung auszuweichen ....

Faar
Beiträge: 1915
Registriert: Sa 8. Sep 2007, 16:23
Wohnort: Brandenburg
Kontaktdaten:

Re: Originale Fehlerseite wirft Status 400 aus anstelle 404

Beitrag von Faar » Do 15. Dez 2022, 13:05

peanut hat geschrieben:
Do 15. Dez 2022, 10:25
https://chat.openai.com/chat

Ich kanns nur jedem empfehlen ... War wieder schön mit sich selbst zu reden :-)))
Wir hatten die Diskussion wegen 404 schon einmal hier.
Das Problem liegt beim CMS, das antwortet immer und folglich gibt es kein 404, auch wenn die Seite (Datenbankinhalt) nicht gefunden wurde.
404 wäre in diesem Fall faktisch auch falsch.

Eine weitere Crux ist, dass der Status zum Zeitpunkt des Feststellens, dass es in der DB keinen Seiteninhalt dazu gibt, bereits gesendet wurde.
Aber auch hier wäre 404 falsch, weil es gibt ja eine Seite, das CMS index.php
Einen Status "DB-Empty" gibt es nicht.

Das Chat-Dingens muss ich noch ausprobieren, auch gerade hinsichtlich der Entwicklung von Contenido.
Aber bin momentan einhändig (OP) und hab zudem Corona, das sich hin zieht.

Aber Murat kann sicher noch was zum Status 404 sagen, er hat das damals auch erklärt.
Fliegt der Bauer übers Dach, ist der Wind weißgott nicht schwach.

peanut
Beiträge: 246
Registriert: Do 25. Nov 2004, 19:34
Kontaktdaten:

Re: Originale Fehlerseite wirft Status 400 aus anstelle 404

Beitrag von peanut » Do 15. Dez 2022, 13:20

Ich dachte mir schon das was spezielles kommt. Ich denke ich fühle mich wohler wenn ich 404 ausliefere

The HyperText Transfer Protocol (HTTP) 400 Bad Request response status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error (for example, malformed request syntax, invalid request message framing, or deceptive request routing)

Hört sich nicht gut an - gute Besserung

############# Das sagt die Ki dazu

is status code 404 better then 400 ?

A HTTP status code of 404 indicates that the requested resource could not be found on the server. A status code of 400 indicates that the request was invalid or could not be understood by the server. In general, a 404 error is a client-side error, meaning that the error is in the request that was sent by the client, while a 400 error is a server-side error, meaning that the server was unable to process the request.

what should i use ?

It depends on the context in which you are using the status codes. If you are developing a web application and want to return a specific error code to the client, you should use the appropriate status code for the situation. For example, if the client sends a request for a resource that does not exist on the server, you should return a 404 status code to indicate that the requested resource could not be found.
du liest nie ein Buch und weisst weise der Bildung auszuweichen ....

Faar
Beiträge: 1915
Registriert: Sa 8. Sep 2007, 16:23
Wohnort: Brandenburg
Kontaktdaten:

Re: Originale Fehlerseite wirft Status 400 aus anstelle 404

Beitrag von Faar » Do 15. Dez 2022, 13:54

hm... bin noch nicht so fit um das zu durchschauen aber hab was altes von mir gefunden:
viewtopic.php?f=115&t=43682&p=180135&hi ... us#p180135
Fliegt der Bauer übers Dach, ist der Wind weißgott nicht schwach.

peanut
Beiträge: 246
Registriert: Do 25. Nov 2004, 19:34
Kontaktdaten:

Re: Originale Fehlerseite wirft Status 400 aus anstelle 404

Beitrag von peanut » Do 15. Dez 2022, 14:01

Ich denke ich versuche einfach das hier

Code: Alles auswählen

<script>
  // Define the httpStatusCode variable
  var httpStatusCode = 400;

  // Check the value of httpStatusCode and change it to 404 if necessary
  if (httpStatusCode == 400) {
    httpStatusCode = 404;
  }

  // Output the updated value of httpStatusCode
  console.log(httpStatusCode);
</script>
In den Body und voila ... Konsole zeigt 404
du liest nie ein Buch und weisst weise der Bildung auszuweichen ....

Antworten