OOP Counter
This commit is contained in:
parent
6bb19ad6b0
commit
49a65d4d1a
7
base/autoloader.php
Normal file
7
base/autoloader.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
spl_autoload_register(function ($name) {
|
||||||
|
$_name = lcfirst($name);
|
||||||
|
|
||||||
|
require_once "/home/k/khofmann/public_html/phpCourse/tasks/oop/classes/$_name/$_name.php";
|
||||||
|
});
|
||||||
@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<?php include_once "../../../base/meta.php" ?>
|
<?php require_once "../../../base/meta.php" ?>
|
||||||
|
|
||||||
<title>Colour Selector</title>
|
<title>Colour Selector</title>
|
||||||
|
|
||||||
@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
// PHP
|
// PHP
|
||||||
include_once "../../../base/settings.php";
|
require_once "../../../base/settings.php";
|
||||||
include_once "../../../base/headers.php";
|
require_once "../../../base/headers.php";
|
||||||
Headers::html();
|
Headers::html();
|
||||||
|
|
||||||
if (!isset($_COOKIE["validation"])) {
|
if (!isset($_COOKIE["validation"])) {
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<?php include_once "../../../base/meta.php" ?>
|
<?php require_once "../../../base/meta.php" ?>
|
||||||
|
|
||||||
<title>Theme Switcher</title>
|
<title>Theme Switcher</title>
|
||||||
|
|
||||||
@ -10,8 +10,8 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
// PHP
|
// PHP
|
||||||
include_once "../../../base/settings.php";
|
require_once "../../../base/settings.php";
|
||||||
include_once "../../../base/headers.php";
|
require_once "../../../base/headers.php";
|
||||||
Headers::html();
|
Headers::html();
|
||||||
|
|
||||||
if (isset($_POST["theme"])) {
|
if (isset($_POST["theme"])) {
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
include_once dirname(__FILE__) . "/../../../../base/settings.php";
|
require_once dirname(__FILE__) . "/../../../../base/settings.php";
|
||||||
include_once dirname(__FILE__) . "/../../../../base/database.php";
|
require_once dirname(__FILE__) . "/../../../../base/database.php";
|
||||||
include_once dirname(__FILE__) . "/functions.php";
|
require_once dirname(__FILE__) . "/functions.php";
|
||||||
|
|
||||||
$db = DB::openConnection();
|
$db = DB::openConnection();
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once dirname(__FILE__) . "/./queries.php";
|
require_once dirname(__FILE__) . "/./queries.php";
|
||||||
|
|
||||||
function getHits($id, $db)
|
function getHits($id, $db)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<?php include_once "../../../base/meta.php" ?>
|
<?php require_once "../../../base/meta.php" ?>
|
||||||
|
|
||||||
<title>Counter DB Tester</title>
|
<title>Counter DB Tester</title>
|
||||||
</head>
|
</head>
|
||||||
@ -10,13 +10,13 @@
|
|||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
// PHP
|
// PHP
|
||||||
include_once "../../../base/settings.php";
|
require_once "../../../base/settings.php";
|
||||||
include_once "../../../base/headers.php";
|
require_once "../../../base/headers.php";
|
||||||
Headers::html();
|
Headers::html();
|
||||||
?>
|
?>
|
||||||
This is a dummy test for the database Counter
|
This is a dummy test for the database Counter
|
||||||
|
|
||||||
<?php include_once "./counter/counter.php" ?>
|
<?php require_once "./counter/counter.php" ?>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<?php include_once "../../base/meta.php" ?>
|
<?php require_once "../../base/meta.php" ?>
|
||||||
|
|
||||||
<title>Calculator</title>
|
<title>Calculator</title>
|
||||||
|
|
||||||
@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
include_once "../../base/settings.php";
|
require_once "../../base/settings.php";
|
||||||
include_once "../../base/headers.php";
|
require_once "../../base/headers.php";
|
||||||
Headers::html();
|
Headers::html();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<?php include_once "../../base/meta.php" ?>
|
<?php require_once "../../base/meta.php" ?>
|
||||||
|
|
||||||
<title>Counter</title>
|
<title>Counter</title>
|
||||||
</head>
|
</head>
|
||||||
@ -10,8 +10,8 @@
|
|||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
// PHP
|
// PHP
|
||||||
include_once "../../base/settings.php";
|
require_once "../../base/settings.php";
|
||||||
include_once "../../base/headers.php";
|
require_once "../../base/headers.php";
|
||||||
Headers::html();
|
Headers::html();
|
||||||
|
|
||||||
$fh = fopen("./data/counter.txt", "r+");
|
$fh = fopen("./data/counter.txt", "r+");
|
||||||
|
|||||||
@ -2,14 +2,14 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<?php include_once "../../base/meta.php" ?>
|
<?php require_once "../../base/meta.php" ?>
|
||||||
<title>Functions</title>
|
<title>Functions</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
include_once "../../base/settings.php";
|
require_once "../../base/settings.php";
|
||||||
include_once "../../base/headers.php";
|
require_once "../../base/headers.php";
|
||||||
Headers::html();
|
Headers::html();
|
||||||
|
|
||||||
/* Aufgabe 1 (A)
|
/* Aufgabe 1 (A)
|
||||||
|
|||||||
@ -2,17 +2,17 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<?php include_once "../../base/meta.php" ?>
|
<?php require_once "../../base/meta.php" ?>
|
||||||
<title>Functions 2</title>
|
<title>Functions 2</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
include_once "../../base/settings.php";
|
require_once "../../base/settings.php";
|
||||||
include_once "../../base/headers.php";
|
require_once "../../base/headers.php";
|
||||||
Headers::html();
|
Headers::html();
|
||||||
|
|
||||||
include_once "../../base/database.php";
|
require_once "../../base/database.php";
|
||||||
|
|
||||||
$db = DB::openConnection();
|
$db = DB::openConnection();
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once "../../../base/settings.php";
|
require_once "../../../base/settings.php";
|
||||||
include_once "../../../base/headers.php";
|
require_once "../../../base/headers.php";
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
$_SESSION["error"] = [];
|
$_SESSION["error"] = [];
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<?php include_once "../../base/meta.php" ?>
|
<?php require_once "../../base/meta.php" ?>
|
||||||
|
|
||||||
<title>Guest Book</title>
|
<title>Guest Book</title>
|
||||||
|
|
||||||
@ -13,10 +13,10 @@
|
|||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
// HTML
|
// HTML
|
||||||
include_once "../../base/icons.php";
|
require_once "../../base/icons.php";
|
||||||
// PHP
|
// PHP
|
||||||
include_once "../../base/settings.php";
|
require_once "../../base/settings.php";
|
||||||
include_once "../../base/headers.php";
|
require_once "../../base/headers.php";
|
||||||
Headers::html();
|
Headers::html();
|
||||||
|
|
||||||
session_name("PHP_SESSION_guestBook");
|
session_name("PHP_SESSION_guestBook");
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once "../../../base/settings.php";
|
require_once "../../../base/settings.php";
|
||||||
include_once "../../../base/headers.php";
|
require_once "../../../base/headers.php";
|
||||||
include_once "../../../base/database.php";
|
require_once "../../../base/database.php";
|
||||||
include_once "../queries.php";
|
require_once "../queries.php";
|
||||||
|
|
||||||
session_name("PHP_SESSION_guestBook");
|
session_name("PHP_SESSION_guestBook");
|
||||||
session_start();
|
session_start();
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once "../../../base/settings.php";
|
require_once "../../../base/settings.php";
|
||||||
include_once "../../../base/headers.php";
|
require_once "../../../base/headers.php";
|
||||||
include_once "../../../base/database.php";
|
require_once "../../../base/database.php";
|
||||||
include_once "../queries.php";
|
require_once "../queries.php";
|
||||||
|
|
||||||
session_name("PHP_SESSION_guestBook");
|
session_name("PHP_SESSION_guestBook");
|
||||||
session_start();
|
session_start();
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once "../../../base/headers.php";
|
require_once "../../../base/headers.php";
|
||||||
|
|
||||||
session_name("PHP_SESSION_guestBook");
|
session_name("PHP_SESSION_guestBook");
|
||||||
session_start();
|
session_start();
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once "../../../base/settings.php";
|
require_once "../../../base/settings.php";
|
||||||
include_once "../../../base/headers.php";
|
require_once "../../../base/headers.php";
|
||||||
include_once "../../../base/database.php";
|
require_once "../../../base/database.php";
|
||||||
include_once "../../../base/helpers.php";
|
require_once "../../../base/helpers.php";
|
||||||
include_once "../queries.php";
|
require_once "../queries.php";
|
||||||
|
|
||||||
session_name("PHP_SESSION_guestBook");
|
session_name("PHP_SESSION_guestBook");
|
||||||
session_start();
|
session_start();
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once "../../base/settings.php";
|
require_once "../../base/settings.php";
|
||||||
include_once "../../base/headers.php";
|
require_once "../../base/headers.php";
|
||||||
include_once "../../base/database.php";
|
require_once "../../base/database.php";
|
||||||
include_once "../../base/helpers.php";
|
require_once "../../base/helpers.php";
|
||||||
include_once "./queries.php";
|
require_once "./queries.php";
|
||||||
|
|
||||||
session_name("PHP_SESSION_guestBook");
|
session_name("PHP_SESSION_guestBook");
|
||||||
session_start();
|
session_start();
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<?php include_once "../../base/meta.php" ?>
|
<?php require_once "../../base/meta.php" ?>
|
||||||
|
|
||||||
<title>Guest Book DB</title>
|
<title>Guest Book DB</title>
|
||||||
|
|
||||||
@ -15,14 +15,14 @@
|
|||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
// HTML
|
// HTML
|
||||||
include_once "../../base/icons.php";
|
require_once "../../base/icons.php";
|
||||||
// PHP
|
// PHP
|
||||||
include_once "../../base/settings.php";
|
require_once "../../base/settings.php";
|
||||||
include_once "../../base/headers.php";
|
require_once "../../base/headers.php";
|
||||||
Headers::html();
|
Headers::html();
|
||||||
include_once "../../base/database.php";
|
require_once "../../base/database.php";
|
||||||
|
|
||||||
include_once "./queries.php";
|
require_once "./queries.php";
|
||||||
|
|
||||||
session_name("PHP_SESSION_guestBook");
|
session_name("PHP_SESSION_guestBook");
|
||||||
session_start();
|
session_start();
|
||||||
@ -99,7 +99,7 @@
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php include_once "../../homework/2/counterDB/counter/counter.php" ?>
|
<?php require_once "../../homework/2/counterDB/counter/counter.php" ?>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<?php include_once "../../base/meta.php" ?>
|
<?php require_once "../../base/meta.php" ?>
|
||||||
|
|
||||||
<title>Guest Book DB - Login</title>
|
<title>Guest Book DB - Login</title>
|
||||||
|
|
||||||
@ -12,9 +12,9 @@
|
|||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
// HTML
|
// HTML
|
||||||
include_once "../../base/icons.php";
|
require_once "../../base/icons.php";
|
||||||
// PHP
|
// PHP
|
||||||
include_once "../../base/headers.php";
|
require_once "../../base/headers.php";
|
||||||
Headers::html();
|
Headers::html();
|
||||||
|
|
||||||
session_name("PHP_SESSION_guestBook");
|
session_name("PHP_SESSION_guestBook");
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<?php include_once "../../base/meta.php" ?>
|
<?php require_once "../../base/meta.php" ?>
|
||||||
|
|
||||||
<title>Guest Book DB - Register</title>
|
<title>Guest Book DB - Register</title>
|
||||||
|
|
||||||
@ -11,9 +11,9 @@
|
|||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
// HTML
|
// HTML
|
||||||
include_once "../../base/icons.php";
|
require_once "../../base/icons.php";
|
||||||
// PHP
|
// PHP
|
||||||
include_once "../../base/headers.php";
|
require_once "../../base/headers.php";
|
||||||
Headers::html();
|
Headers::html();
|
||||||
|
|
||||||
session_name("PHP_SESSION_guestBook");
|
session_name("PHP_SESSION_guestBook");
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<?php include_once "../../base/meta.php" ?>
|
<?php require_once "../../base/meta.php" ?>
|
||||||
|
|
||||||
<link href="./css/head.css" rel="stylesheet" />
|
<link href="./css/head.css" rel="stylesheet" />
|
||||||
|
|
||||||
@ -11,12 +11,12 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
include_once "../../base/settings.php";
|
require_once "../../base/settings.php";
|
||||||
include_once "../../base/headers.php";
|
require_once "../../base/headers.php";
|
||||||
Headers::html();
|
Headers::html();
|
||||||
include_once "../../base/database.php";
|
require_once "../../base/database.php";
|
||||||
|
|
||||||
include_once "./queries.php";
|
require_once "./queries.php";
|
||||||
$query = $base;
|
$query = $base;
|
||||||
|
|
||||||
session_name("PHP_SESSION_itemList");
|
session_name("PHP_SESSION_itemList");
|
||||||
|
|||||||
180
tasks/oop/classes/counter/counter.php
Normal file
180
tasks/oop/classes/counter/counter.php
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
<?php
|
||||||
|
require_once dirname(__FILE__) . "/../../../../base/database.php";
|
||||||
|
|
||||||
|
class Counter
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Private members
|
||||||
|
*/
|
||||||
|
|
||||||
|
private PDO $db;
|
||||||
|
private string $siteID;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function __construct(string $siteID = null)
|
||||||
|
{
|
||||||
|
$this->db = DB::openConnection();
|
||||||
|
|
||||||
|
if (empty($siteID)) {
|
||||||
|
$this->siteID = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["REQUEST_URI"]) - 256);
|
||||||
|
} else {
|
||||||
|
$this->siteID = $siteID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Render Component
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
$this->cleanupIPs();
|
||||||
|
$hasVisited = $this->hasVisited();
|
||||||
|
if (!$hasVisited) {
|
||||||
|
$this->addHit();
|
||||||
|
$this->addIp();
|
||||||
|
}
|
||||||
|
|
||||||
|
$ret =
|
||||||
|
<<<EOT
|
||||||
|
<style>
|
||||||
|
.span-v3Yq3 {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 6px 6px 4px;
|
||||||
|
border-radius: 3px;
|
||||||
|
background: #cccccc;
|
||||||
|
margin-right: -2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.center-v3Yq3 {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 5px;
|
||||||
|
width: 50%;
|
||||||
|
margin: 20px auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-v3Yq3 {
|
||||||
|
color: #aaaaaa;
|
||||||
|
font-size: 12px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div>
|
||||||
|
<div class="center-v3Yq3">
|
||||||
|
EOT;
|
||||||
|
foreach (mb_str_split(($this->getHits()) . "") as $digit) {
|
||||||
|
$ret .=
|
||||||
|
<<<EOT
|
||||||
|
<span class="span-v3Yq3">$digit</span>
|
||||||
|
EOT;
|
||||||
|
}
|
||||||
|
$ret .=
|
||||||
|
<<<EOT
|
||||||
|
</div>
|
||||||
|
<div class="center-v3Yq3 message-v3Yq3">
|
||||||
|
Have visited this site.
|
||||||
|
EOT;
|
||||||
|
if (!$hasVisited) {
|
||||||
|
$ret .=
|
||||||
|
<<<EOT
|
||||||
|
<br />
|
||||||
|
This is your first visit tody
|
||||||
|
EOT;
|
||||||
|
}
|
||||||
|
$ret .=
|
||||||
|
<<<EOT
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
EOT;
|
||||||
|
|
||||||
|
echo $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Implementation
|
||||||
|
*/
|
||||||
|
|
||||||
|
private function getHits()
|
||||||
|
{
|
||||||
|
$query = "
|
||||||
|
SELECT
|
||||||
|
hits
|
||||||
|
FROM
|
||||||
|
Counter
|
||||||
|
WHERE
|
||||||
|
siteID LIKE :SID";
|
||||||
|
|
||||||
|
$stmt = $this->db->prepare($query);
|
||||||
|
$stmt->bindValue(":SID", $this->siteID);
|
||||||
|
$stmt->execute();
|
||||||
|
$hits = $stmt->fetch(PDO::FETCH_COLUMN);
|
||||||
|
return $hits !== false ? $hits : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function addHit()
|
||||||
|
{
|
||||||
|
$query = "
|
||||||
|
INSERT INTO
|
||||||
|
Counter(siteID, hits)
|
||||||
|
VALUES
|
||||||
|
(:SID, 1)
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
hits = hits + 1";
|
||||||
|
|
||||||
|
$stmt = $this->db->prepare($query);
|
||||||
|
$stmt->bindValue(":SID", $this->siteID);
|
||||||
|
$stmt->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function addIP()
|
||||||
|
{
|
||||||
|
$query = "
|
||||||
|
INSERT INTO
|
||||||
|
CounterIP(siteID, ip, timestamp)
|
||||||
|
VALUES
|
||||||
|
(:SID, :IP, NOW())";
|
||||||
|
|
||||||
|
$stmt = $this->db->prepare($query);
|
||||||
|
$stmt->bindValue(":SID", $this->siteID);
|
||||||
|
$stmt->bindValue(":IP", $_SERVER['REMOTE_ADDR']);
|
||||||
|
$stmt->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function cleanupIPs()
|
||||||
|
{
|
||||||
|
$query = "
|
||||||
|
DELETE FROM
|
||||||
|
CounterIP
|
||||||
|
WHERE
|
||||||
|
TIMESTAMPDIFF(MINUTE, timestamp, NOW()) > 1";
|
||||||
|
|
||||||
|
$stmt = $this->db->prepare($query);
|
||||||
|
$stmt->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function hasVisited()
|
||||||
|
{
|
||||||
|
$query = "
|
||||||
|
SELECT
|
||||||
|
COUNT(*)
|
||||||
|
FROM
|
||||||
|
CounterIP
|
||||||
|
WHERE
|
||||||
|
siteID = :SID
|
||||||
|
AND
|
||||||
|
ip = :IP
|
||||||
|
AND
|
||||||
|
TIMESTAMPDIFF(MINUTE, timestamp, NOW()) <= 1";
|
||||||
|
|
||||||
|
$stmt = $this->db->prepare($query);
|
||||||
|
$stmt->bindValue(":SID", $this->siteID);
|
||||||
|
$stmt->bindValue(":IP", $_SERVER['REMOTE_ADDR']);
|
||||||
|
$stmt->execute();
|
||||||
|
$cnt = $stmt->fetch(PDO::FETCH_COLUMN);
|
||||||
|
return $cnt > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
21
tasks/oop/counter/index.php
Normal file
21
tasks/oop/counter/index.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<?php require_once "../../../base/meta.php" ?>
|
||||||
|
|
||||||
|
<title>FieldValidator Test</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<?php
|
||||||
|
require_once "../../../base/settings.php";
|
||||||
|
require_once "../../../base/headers.php";
|
||||||
|
require_once "../../../base/autoloader.php";
|
||||||
|
Headers::html();
|
||||||
|
|
||||||
|
(new Counter())->render();
|
||||||
|
?>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@ -2,19 +2,19 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<?php include_once "../../../base/meta.php" ?>
|
<?php require_once "../../../base/meta.php" ?>
|
||||||
|
|
||||||
<title>FieldValidator Test</title>
|
<title>FieldValidator Test</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
include_once "../../../base/settings.php";
|
require_once "../../../base/settings.php";
|
||||||
include_once "../../../base/headers.php";
|
require_once "../../../base/headers.php";
|
||||||
Headers::html();
|
Headers::html();
|
||||||
|
|
||||||
//Testdatei für die Klasse FieldValidator
|
//Testdatei für die Klasse FieldValidator
|
||||||
include_once "../classes/fieldValidator/fieldValidator.php";
|
require_once "../classes/fieldValidator/fieldValidator.php";
|
||||||
|
|
||||||
$validators = [
|
$validators = [
|
||||||
FieldValidator::create("Empty Valid", "", "string"),
|
FieldValidator::create("Empty Valid", "", "string"),
|
||||||
|
|||||||
@ -2,20 +2,20 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<?php include_once "../../../base/meta.php" ?>
|
<?php require_once "../../../base/meta.php" ?>
|
||||||
|
|
||||||
<title>FormValidator Test</title>
|
<title>FormValidator Test</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
include_once "../../../base/settings.php";
|
require_once "../../../base/settings.php";
|
||||||
include_once "../../../base/headers.php";
|
require_once "../../../base/headers.php";
|
||||||
Headers::html();
|
Headers::html();
|
||||||
|
|
||||||
//Testdatei für die Klasse FormValidator
|
//Testdatei für die Klasse FormValidator
|
||||||
include_once "../classes/fieldValidator/fieldValidator.php";
|
require_once "../classes/fieldValidator/fieldValidator.php";
|
||||||
include_once "../classes/formValidator/formValidator.php";
|
require_once "../classes/formValidator/formValidator.php";
|
||||||
|
|
||||||
$form = FormValidator::create(
|
$form = FormValidator::create(
|
||||||
FieldValidator::create("Empty Valid", "", "string"),
|
FieldValidator::create("Empty Valid", "", "string"),
|
||||||
|
|||||||
@ -2,19 +2,19 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<?php include_once "../../../base/meta.php" ?>
|
<?php require_once "../../../base/meta.php" ?>
|
||||||
|
|
||||||
<title>Person Test</title>
|
<title>Person Test</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
include_once "../../../base/settings.php";
|
require_once "../../../base/settings.php";
|
||||||
include_once "../../../base/headers.php";
|
require_once "../../../base/headers.php";
|
||||||
Headers::html();
|
Headers::html();
|
||||||
|
|
||||||
//Testdatei für die Klasse Hyperlink
|
//Testdatei für die Klasse Hyperlink
|
||||||
include_once "../classes/hyperlink/hyperlink.php";
|
require_once "../classes/hyperlink/hyperlink.php";
|
||||||
|
|
||||||
//Objektinstanzen
|
//Objektinstanzen
|
||||||
$link1 = new Hyperlink("https://www.google.de", "Google");
|
$link1 = new Hyperlink("https://www.google.de", "Google");
|
||||||
|
|||||||
@ -2,18 +2,18 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<?php include_once "../../../base/meta.php" ?>
|
<?php require_once "../../../base/meta.php" ?>
|
||||||
|
|
||||||
<title>Person Test</title>
|
<title>Person Test</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
include_once "../../../base/settings.php";
|
require_once "../../../base/settings.php";
|
||||||
include_once "../../../base/headers.php";
|
require_once "../../../base/headers.php";
|
||||||
Headers::html();
|
Headers::html();
|
||||||
|
|
||||||
include_once "../classes/person/person.php";
|
require_once "../classes/person/person.php";
|
||||||
$person = new Person("John Doe", 170, new DateTime("01-01-1970"));
|
$person = new Person("John Doe", 170, new DateTime("01-01-1970"));
|
||||||
|
|
||||||
echo $person;
|
echo $person;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once "../../base/settings.php";
|
require_once "../../base/settings.php";
|
||||||
include_once "../../base/headers.php";
|
require_once "../../base/headers.php";
|
||||||
Headers::html();
|
Headers::html();
|
||||||
|
|
||||||
$personen = array("Felix", "Berta", "Dalia", "Cecil", "Axel", "Elmar");
|
$personen = array("Felix", "Berta", "Dalia", "Cecil", "Axel", "Elmar");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user