Hétfői Backend óra

This commit is contained in:
Tóth Ádám 2024-11-20 09:38:55 +01:00
parent ff0026e138
commit cb6d759caa
5 changed files with 54 additions and 0 deletions

Binary file not shown.

View File

@ -1,6 +1,17 @@
<?php <?php
session_start(); session_start();
$celkonyvtar = "kepek/"; $celkonyvtar = "kepek/";
function vizjeljpg($kepfajl, $celkonyvtar) {
$img = imagecreatefromjpeg($kepfajl);
$wmcolor = imagecolorallocatealpha($img, 255, 255, 255, 25);
imagefttext($img, 18,0,0,24, $wmcolor, "Vera.ttf", "WATERMARK");
imagejpeg($img, $celkonyvtar."vizejeles.jpg", 75);
}
if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (!is_dir($celkonyvtar)) { if (!is_dir($celkonyvtar)) {
mkdir($celkonyvtar); mkdir($celkonyvtar);
@ -37,7 +48,9 @@
if (move_uploaded_file($_FILES["kepfajl"]["tmp_name"], $celfajl) == true) { if (move_uploaded_file($_FILES["kepfajl"]["tmp_name"], $celfajl) == true) {
if ($vanmar == 0) { if ($vanmar == 0) {
$_SESSION["kepek"][] = $celfajl; $_SESSION["kepek"][] = $celfajl;
vizjeljpg($celfajl, $celkonyvtar);
} }
} }
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

View File

@ -0,0 +1,41 @@
<?php
class Tanulo {
public $nev;
public $kor;
public $jegyek = [];
public function __construct($nev, $kor) {
$this->nev = $nev;
$this->kor = $kor;
}
public function adjegy($jegy) {
$this->jegyek[] = $jegy;
}
public function atlagkiszamit() {
if (count($this->jegyek) == 0) {
return 0;
}
else {
return array_sum($this->jegyek) / count($this->jegyek);
}
}
public function adatkiir() {
$atlag = $this->atlagkiszamit();
echo "Név: {$this->nev}, Kor: {$this->kor}, Átlag: {$atlag}";
}
}
$tan1 = new Tanulo("Kis Péter", 15);
$tan1->adjegy(5);
$tan1->adjegy(1);
$tan1->adjegy(3);
$tan1->adjegy(2);
$tan1->adatkiir();
?>