Die üblichen Übungen 0000002

Benutzeravatar
davidvajda.de
Site Admin
Beiträge: 1478
Registriert: Di Jul 18, 2023 8:36 pm
Wohnort: D-72072, Tübingen
Kontaktdaten:

Re: Die üblichen Übungen 0000002

Beitrag von davidvajda.de »

Bild

Code: Alles auswählen

<?php
session_start ();
?>

<form method="POST" action="./form20240302.php">
<input type="text" name="form2024030201"></input>
<input type="submit">
</form>

<?php
echo session_id () . "<br>\n";

setcookie ("form2024030202", "Hallo, ich bin Cookie 1", time () + 3600);

echo htmlentities ($_POST ["form2024030201"]) . "<br>\n";
echo htmlentities ($_COOKIE ["form2024030202"]) . "<br>\n";
echo htmlentities ($_COOKIE ["form2024030203"]) . "<br>\n";

session_destroy ();
?>

Code: Alles auswählen

POST http://localhost/mysql20240217/20240302/form20240302.php HTTP/1.1
host: localhost
Cookie: form2024030203=Hallo, ich bin Cookie 2
Content-Type: application/x-www-form-urlencoded
Content-Length: 37

form2024030201=Hallo, ich bin Datum 1

Code: Alles auswählen

Trying ::1...
Connected to localhost.
Escape character is '^]'.
HTTP/1.1 200 OK
Date: Sat, 02 Mar 2024 14:24:27 GMT
Server: Apache/2.4.57 (Debian)
Set-Cookie: PHPSESSID=v3t3ka4qj26smdeoolrsb7k354; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Set-Cookie: form2024030202=Hallo%2C%20ich%20bin%20Cookie%201; expires=Sat, 02 Mar 2024 15:24:27 GMT; Max-Age=3600
Vary: Accept-Encoding
Content-Length: 222
Content-Type: text/html; charset=UTF-8


<form method="POST" action="./form20240302.php">
<input type="text" name="form2024030201"></input>
<input type="submit">
</form>

v3t3ka4qj26smdeoolrsb7k354<br>
Hallo, ich bin Datum 1<br>
<br>
Hallo, ich bin Cookie 2<br>

Code: Alles auswählen

<?php
session_start ();

include ("/home/david/mysqldata.php");

$db = new PDO ("mysql: host=localhost", $MYSQL_USER, $MYSQL_PASSWORD);

$sql = "CREATE DATABASE mysql20240302" . session_id () . "; ";
$db->query ($sql);

$sql = "USE mysql20240302" . session_id () . "; ";
$db->query ($sql);

$sql = "CREATE TABLE a (x1 INTEGER, x2 INTEGER); ";
$db->query ($sql);

$sql = "CREATE TABLE b (y1 INTEGER, y2 INTEGER); ";
$db->query ($sql);

$sql = "INSERT INTO a (x1, x2) VALUES (0, 0);";
$db->query ($sql);

$sql = "INSERT INTO a (x1, x2) VALUES (0, 1); INSERT INTO a (x1, x2) VALUES (1, 0); INSERT INTO a (x1, x2) VALUES (1, 1); INSERT INTO a (x1, x2) VALUES (2, 7);";
$db->query ($sql);

$sql = "INSERT INTO b (y1, y2) VALUES (0, 1); INSERT INTO b (y1, y2) VALUES (1, 0); INSERT INTO b (y1, y2) VALUES (2, 7);";
$db->query ($sql);

$sql = "SELECT x1, x2 FROM a;";
$stmt = $db->query ($sql);
while ($row = $stmt->fetch ())
    echo $row [0] . ", " . $row [1] . "<br>\n";
echo "<br>\n";

$sql = "SELECT y1, y2 FROM b;";
$stmt = $db->query ($sql);
while ($row = $stmt -> fetch ())
    echo $row [0] . ", " . $row [1] . "<br>\n";
echo "<br>\n";

$sql = "SELECT x1, x2, y1, y2 FROM a LEFT JOIN b ON a.x1 = b.y1;";
$stmt = $db->query ($sql);
while ($row = $stmt -> fetch ())
    echo $row [0] . ", " . $row [1] . ", " . $row [2] . ", " . $row [3] . "<br>\n";
echo "<br>\n";

$sql = "DROP DATABASE mysql20240302" . session_id () . "; ";
$db->query ($sql);

session_destroy ();
?>

Code: Alles auswählen

0, 0<br>
0, 1<br>
1, 0<br>
1, 1<br>
2, 7<br>
<br>
0, 1<br>
1, 0<br>
2, 7<br>
<br>
0, 0, 0, 1<br>
0, 1, 0, 1<br>
1, 0, 1, 0<br>
1, 1, 1, 0<br>
2, 7, 2, 7<br>
<br>

Code: Alles auswählen

<?php
session_start ();

include ("/home/david/mysqldata.php");

$db = new PDO ("mysql: host=localhost", $MYSQL_USER, $MYSQL_PASSWORD);

$sql = "CREATE DATABASE q20240302" . session_id () . "; ";
$db->query ($sql);

$sql = "USE q20240302" . session_id () . "; ";
$db->query ($sql);

$sql = "CREATE TABLE a (x INTEGER); ";
$db->query ($sql);

$sql = "CREATE TABLE b (x INTEGER); ";
$db->query ($sql);

$sql = "CREATE TABLE c (x INTEGER); ";
$db->query ($sql);

for ($i = 0;  $i < 24;  $i++) {
    $sql = "INSERT INTO a (x) VALUES (\"" . rand () % 28 . "\"); ";
    $db->query ($sql);
    $sql = "INSERT INTO b (x) VALUES (\"" . rand () % 32 . "\"); ";
    $db->query ($sql);
    $sql = "INSERT INTO c (x) VALUES (\"" . rand () % 64 . "\"); ";
    $db->query ($sql);
}

$sql = "SELECT x FROM (SELECT x FROM a UNION SELECT x FROM b) x;";
$stmt = $db->query ($sql);
while ($row = $stmt -> fetch ())
    echo $row [0] . ", ";
echo "<br>\n";

$sql = "SELECT x FROM (SELECT x FROM a UNION SELECT x FROM c) x;";
$stmt = $db->query ($sql);
while ($row = $stmt -> fetch ())
    echo $row [0] . ", ";
echo "<br>\n";

$sql = "SELECT x FROM (SELECT x FROM b UNION SELECT x FROM c) x;";
$stmt = $db->query ($sql);
while ($row = $stmt -> fetch ())
    echo $row [0] . ", ";
echo "<br>\n";

$sql = "SELECT x FROM (SELECT x FROM a INTERSECT SELECT x FROM b) x;";
$stmt = $db->query ($sql);
while ($row = $stmt -> fetch ())
    echo $row [0] . ", ";
echo "<br>\n";

$sql = "SELECT x FROM (SELECT x FROM a INTERSECT SELECT x FROM c) x;";
$stmt = $db->query ($sql);
while ($row = $stmt -> fetch ())
    echo $row [0] . ", ";
echo "<br>\n";

$sql = "SELECT x FROM (SELECT x FROM b INTERSECT SELECT x FROM c) x;";
$stmt = $db->query ($sql);
while ($row = $stmt -> fetch ())
    echo $row [0] . ", ";
echo "<br>\n";

$sql = "SELECT x FROM (
            SELECT x FROM (SELECT x FROM a UNION SELECT x FROM b) x
                INTERSECT
            SELECT x FROM c
    ) x;";
$stmt = $db->query ($sql);
while ($row = $stmt -> fetch ())
    echo $row [0] . ", ";
echo "<br>\n";

$sql = "SELECT x FROM (
            SELECT x FROM (SELECT x FROM a INTERSECT SELECT x FROM c) x
                UNION
            SELECT x FROM (SELECT x FROM b INTERSECT SELECT x FROM c) x
    ) x;";
$stmt = $db->query ($sql);
while ($row = $stmt -> fetch ())
    echo $row [0] . ", ";
echo "<br>\n";

$sql = "SELECT x FROM (
            SELECT x FROM (SELECT x FROM a UNION SELECT x FROM c) x
                INTERSECT
            SELECT x FROM b
    ) x;";
$stmt = $db->query ($sql);
while ($row = $stmt -> fetch ())
    echo $row [0] . ", ";
echo "<br>\n";

$sql = "SELECT x FROM (
            SELECT x FROM (SELECT x FROM a INTERSECT SELECT x FROM b) x
                INTERSECT
            SELECT x FROM (SELECT x FROM c INTERSECT SELECT x FROM b) x
    ) x;";
$stmt = $db->query ($sql);
while ($row = $stmt -> fetch ())
    echo $row [0] . ", ";
echo "<br>\n";

$sql = "SELECT x FROM (
            SELECT x FROM (SELECT x FROM b UNION SELECT x FROM c) x
                INTERSECT
            SELECT x FROM a
    ) x;";
$stmt = $db->query ($sql);
while ($row = $stmt -> fetch ())
    echo $row [0] . ", ";
echo "<br>\n";

$sql = "SELECT x FROM (
            SELECT x FROM (SELECT x FROM b INTERSECT SELECT x FROM a) x
                UNION
            SELECT x FROM (SELECT x FROM c INTERSECT SELECT x FROM a) x
    ) x;";
$stmt = $db->query ($sql);
while ($row = $stmt -> fetch ())
    echo $row [0] . ", ";
echo "<br>\n";


$sql = "DROP DATABASE q20240302" . session_id () . "; ";
$db->query ($sql);

session_destroy ();
?>

Code: Alles auswählen

4, 20, 16, 1, 2, 8, 15, 11, 21, 3, 24, 19, 13, 23, 5, 26, 0, 27, 6, 22, 29, 12, 9, 7, 17, 14, <br>
4, 20, 16, 1, 2, 8, 15, 11, 21, 3, 24, 19, 13, 23, 5, 26, 0, 27, 42, 48, 46, 14, 44, 18, 47, 32, 53, 56, 6, 9, 34, 28, <br>
6, 19, 22, 29, 23, 5, 12, 2, 13, 9, 16, 1, 27, 7, 8, 20, 17, 24, 14, 11, 42, 48, 46, 44, 18, 47, 32, 53, 56, 34, 28, <br>
20, 16, 1, 2, 8, 11, 24, 19, 13, 23, 5, 27, <br>
20, 16, 11, 24, 5, <br>
6, 5, 9, 16, 20, 24, 14, 11, <br>
20, 16, 11, 24, 5, 6, 9, 14, <br>
20, 16, 11, 24, 5, 6, 9, 14, <br>
20, 16, 1, 2, 8, 11, 24, 19, 13, 23, 5, 27, 14, 6, 9, <br>
20, 16, 11, 24, 5, <br>
19, 23, 5, 2, 13, 16, 1, 27, 8, 20, 24, 11, <br>
19, 23, 5, 2, 13, 16, 1, 27, 8, 20, 24, 11, <br>

Code: Alles auswählen

#!/bin/bash

if [[  "$1" == "David" && "$2" == "Vajda" ]]
then
    echo "Ja, das bin sehr wahrscheinlich ich"
elif [ "$1" == "David Vajda" ]
then
    echo "Ja, das bin sehr wahrscheinlich ich"
elif [[ "$1" == "David" && -z "$2" ]]
then
    echo "Ja, das koennte ich sein"
elif [[ "$1" == "Vajda" && -z "$2" ]]
then
    echo "Das koennte ich sein"
elif [ -n "$1" ]
then
    echo "Das bin ich eher nicht"
else
    echo "Hallo Welt"
    i=0
    while [ $i -lt 10 ]
    do
        echo "Hallo zum $(($i+1))"
        i=$(($i+1))
    done
    a=(Ich bin ein Array)
    a+=(und zwar mit Fortsetzung)
    i=0
    while [ $i -lt 8 ]
    do
        echo "${a[$i]}"
        i=$(($i+1))
    done
    for s in "${a[@]}"
    do
        echo "$s"
    done
    l=$(ls)
    for s in $l
    do
        echo "$s"
    done
fi

Code: Alles auswählen

#!/bin/bash

/bin/bash myhello.sh "David" "Vajda"
/bin/bash myhello.sh "David Vajda"
/bin/bash myhello.sh "Vajda"
/bin/bash myhello.sh "David"
/bin/bash myhello.sh "Max Mustermann"
/bin/bash myhello.sh

Code: Alles auswählen

Ja, das bin sehr wahrscheinlich ich
Ja, das bin sehr wahrscheinlich ich
Das koennte ich sein
Ja, das koennte ich sein
Das bin ich eher nicht
Hallo Welt
Hallo zum 1
Hallo zum 2
Hallo zum 3
Hallo zum 4
Hallo zum 5
Hallo zum 6
Hallo zum 7
Hallo zum 8
Hallo zum 9
Hallo zum 10
Ich
bin
ein
Array
und
zwar
mit
Fortsetzung
Ich
bin
ein
Array
und
zwar
mit
Fortsetzung
myhelloexec.sh
myhello.out
myhello.sh
Bild

Code: Alles auswählen

 0 0 0 0 0    0
 1 0 0 0 1    0
 2 0 0 1 0    0
 3 0 0 1 1    0
 4 0 1 0 0    0
 5 0 1 0 1    0
 6 0 1 1 0    0
 7 0 1 1 1    1
 8 1 0 0 0    0
 9 1 0 0 1    1
10 1 0 1 0    0
11 1 0 1 1    0
12 1 1 0 0    1
13 1 1 0 1    0
14 1 1 1 0    0
15 1 1 1 1    1


 7 0 1 1 1    1
 9 1 0 0 1    1
12 1 1 0 0    1
15 1 1 1 1    1


Gruppe 2:
 9 1 0 0 1    1
12 1 1 0 0    1
Gruppe 3:
 7 0 1 1 1    1
Gruppe 4:
15 1 1 1 1    1


9           1 0 0 1     1
12          1 1 0 0     1
7:15        - 1 1 1     1

    y <= (x3 and not x2 and not x1 and x0) or
            (x3 and x2 and not x1 and not x0) or
            (x2 and x1 and x0);
    y <= not (
            (not x3 or x2 or x1 or not x0) and
            (not x3 or not x2 or x1 or x0) and
            (not x3 or not x2 or not x1)
        );

library ieee;
use ieee.std_logic_1164.all;

entity quine20240302 is
port (
    x3, x2, x1, x0: in std_logic;
    y: out std_logic
);
end;

architecture behaviour of quine20240302 is
begin
    y <= (x3 and not x2 and not x1 and x0) or
            (x3 and x2 and not x1 and not x0) or
            (x2 and x1 and x0);
end;

library ieee;
use ieee.std_logic_1164.all;

entity quine20240302testbench is
port (
    y: out std_logic
);
end;

architecture behaviour of quine20240302testbench is
    component quine20240302
    port (
        x3, x2, x1, x0: in std_logic;
        y: out std_logic
    );
    end component;
    signal x3, x2, x1, x0: std_logic;
begin
    q: quine20240302 PORT MAP (x3=>x3, x2=>x2, x1=>x1, x0=>x0, y=>y);


Code: Alles auswählen

library ieee;
use ieee.std_logic_1164.all;

entity quine20240302 is
port (
    x3, x2, x1, x0: in std_logic;
    y: out std_logic
);
end;

architecture behaviour of quine20240302 is
begin
    y <= (x3 and not x2 and not x1 and x0) or
            (x3 and x2 and not x1 and not x0) or
            (x2 and x1 and x0);
end;

library ieee;
use ieee.std_logic_1164.all;

entity quine20240302testbench is
port (
    y: out std_logic
);
end;

architecture behaviour of quine20240302testbench is
    component quine20240302
    port (
        x3, x2, x1, x0: in std_logic;
        y: out std_logic
    );
    end component;
    signal x3, x2, x1, x0: std_logic;
begin
    q: quine20240302 PORT MAP (x3=>x3, x2=>x2, x1=>x1, x0=>x0, y=>y);

    x0 <= '0' after 0 ns, '1' after 10 ns, '0' after 20 ns, '1' after 30 ns, '0' after 40 ns, '1' after 50 ns, '0' after 60 ns, '1' after 70 ns, '0' after 80 ns, '1' after 90 ns, '0' after 100 ns, '1' after 110 ns, '0' after 120 ns, '1' after 130 ns, '0' after 140 ns, '1' after 150 ns;

    x1 <= '0' after 0 ns, '0' after 10 ns, '1' after 20 ns, '1' after 30 ns, '0' after 40 ns, '0' after 50 ns, '1' after 60 ns, '1' after 70 ns, '0' after 80 ns, '0' after 90 ns, '1' after 100 ns, '1' after 110 ns, '0' after 120 ns, '0' after 130 ns, '1' after 140 ns, '1' after 150 ns;

    x2 <= '0' after 0 ns, '0' after 10 ns, '0' after 20 ns, '0' after 30 ns, '1' after 40 ns, '1' after 50 ns, '1' after 60 ns, '1' after 70 ns, '0' after 80 ns, '0' after 90 ns, '0' after 100 ns, '0' after 110 ns, '1' after 120 ns, '1' after 130 ns, '1' after 140 ns, '1' after 150 ns;

    x3 <= '0' after 0 ns, '0' after 10 ns, '0' after 20 ns, '0' after 30 ns, '0' after 40 ns, '0' after 50 ns, '0' after 60 ns, '0' after 70 ns, '1' after 80 ns, '1' after 90 ns, '1' after 100 ns, '1' after 110 ns, '1' after 120 ns, '1' after 130 ns, '1' after 140 ns, '1' after 150 ns;
end;
Antworten