server update

This commit is contained in:
asandikci 2024-01-07 03:27:44 +03:00
parent b1298affe8
commit 91ceee534c
No known key found for this signature in database
GPG key ID: 25C67A03B5666BC1
5 changed files with 214 additions and 53 deletions

72
assets/css/yurdle.css Normal file
View file

@ -0,0 +1,72 @@
#tebriks {
text-align: center;
font-size: larger;
font-weight: 800;
color: blue;
background-color: coral;
padding: 3px;
border: 1px solid white;
}
.innot {
text-align: center;
}
.guess-table {
width: 100%;
display: table;
overflow-x: auto;
-ms-overflow-style: none;
scrollbar-width: none;
}
@media screen and (max-device-width: 1000px) {
.guess-table {
display: block;
overflow-x: auto;
}
}
.guess-tr {}
.guess-th {
border: aliceblue 3px solid;
}
.guess-td {
text-align: center;
border: aliceblue 1px solid;
}
.type0 {
background-color: red;
font-weight: 800;
}
.type1 {
background-color: orange;
color: darkblue;
font-weight: 500;
}
.type2 {
background-color: green;
}
.type10 {
background-color: red;
font-weight: 800;
}
.type10::after {
content: "👇"
}
.type12 {
background-color: red;
font-weight: 800;
}
.type12::after {
content: "👆"
}

View file

@ -2,6 +2,8 @@
rm -rf build/ rm -rf build/
mkdir build mkdir build
composer update
composer install
cp -r ./* build/ cp -r ./* build/
cp -r ../YurdleBackend/* build/ cp -r ../YurdleBackend/* build/
cd build/ || exit cd build/ || exit

View file

@ -217,8 +217,10 @@ _folder_permissions() {
useradd -g $MAIN_NAME $MAIN_NAME useradd -g $MAIN_NAME $MAIN_NAME
cd $WEB_ROOT_DIR || exit cd $WEB_ROOT_DIR || exit
chown $MAIN_NAME:nginx -R . chown $MAIN_NAME:nginx -R .
if [[ $SECRET_SERVER == "true" ]]; then
cd $WEB_SERVER_DIR || exit cd $WEB_SERVER_DIR || exit
chown $MAIN_NAME:nginx -R . chown $MAIN_NAME:nginx -R .
fi
} }
if [[ $# -eq 0 ]]; then if [[ $# -eq 0 ]]; then
@ -293,7 +295,7 @@ elif [[ $1 == "docker" ]]; then
cp -r /server/$BUILD_DIR/* $WEB_SERVER_DIR/ cp -r /server/$BUILD_DIR/* $WEB_SERVER_DIR/
fi fi
apt install php php-fpm php-cli composer -y apt install php php-fpm php-cli -y
locale-gen tr_TR locale-gen tr_TR
# _setup_database # _setup_database

145
index.php
View file

@ -9,6 +9,7 @@
<meta name="author" content="Aliberk Sandıı"> <meta name="author" content="Aliberk Sandıı">
<link rel="stylesheet" href="/assets/css/main.css"> <link rel="stylesheet" href="/assets/css/main.css">
<link rel="stylesheet" href="/assets/css/yurdle.css">
<title>Yurdle | İFL</title> <title>Yurdle | İFL</title>
</head> </head>
@ -20,15 +21,26 @@
</header> </header>
<article class="sections"> <article class="sections">
<div class="section" style="height:100vh"> <div class="section" style="height: max-content;
min-height: 100vh;">
<form class="centered" style="margin-top: 10vh;" action="index.php" method="post"> <form class="centered" style="margin-top: 10vh;" action="index.php" method="post">
<label style="margin-bottom:1vh;" for="mainInput">Yurtlu Öğrencinin İsmini Giriniz</label> <label style="margin-bottom:1vh;" for="mainInput">Yurtlu Öğrencinin İsmini Giriniz</label>
<div><input style="width:80%;" class="input" type="text" id="mainInput" name="mainInput" placeholder="İsim Soyisim" /><input style="width:20%;" class="input" type="submit" value="Dene" /></div> <div><input style="width:80%;" class="input" type="text" id="mainInput" name="mainInput" placeholder="İsim Soyisim" /><input style="width:20%;" class="input" type="submit" value="Dene" /></div>
</form> </form>
<div id="tahminler"> <div id="tebriks">
</div> </div>
<div style="margin-top:auto;text-align:center;">Veri Sorumlusu: Ömer Arda Muratoğlu.<br>Her türlü kaldırılmasını, eklenmesini ve/veya değiştirilmesi istediğiniz veriler için kendisi ile iletişime geçiniz !</div> <div id="tahminler">
</div>
<div id="notices">
</div>
<hr style="width: 100%; box-sizing: border-box;">
<div id="sorumli" style="margin-top:auto;text-align:center;">Veri Sorumlusu: <b>Ömer Arda Muratoğlu</b><br>Her türlü kaldırılmasını, eklenmesini ve/veya değiştirilmesi istediğiniz veriler için kendisi ile iletişime geçiniz !</div>
<hr style="width: 100%; box-sizing: border-box;">
<div style="text-align:center;">Son veri güncelleme: <span id="latest-data"></span> <div style="text-align:center;">Son veri güncelleme: <span id="latest-data"></span>
</div> </div>
</div> </div>
@ -47,6 +59,16 @@
return a.toDateString() == b.toDateString(); return a.toDateString() == b.toDateString();
} }
if (localStorage.getItem("win") == null) {
localStorage.setItem("win", "none");
}
document.getElementById("tebriks").style.display = "none";
if (localStorage.getItem("win") != null && localStorage.getItem("win") === "winned") {
console.log(localStorage.getItem("win"));
document.getElementById("tebriks").style.display = "block";
document.getElementById("tebriks").innerHTML = "Tebrikler, günün şanslı kişisini buldun!"
}
// LOCAL STORAGE AND GUESS HANDLING // LOCAL STORAGE AND GUESS HANDLING
date = new Date(); date = new Date();
if (localStorage.getItem("latest_visit") === null) { if (localStorage.getItem("latest_visit") === null) {
@ -84,67 +106,112 @@
} }
var gj = JSON.parse('{"Guesses":[], "Values":[]}'); // guess json var gj = JSON.parse('{"Guesses":[], "Values":[]}'); // guess json
if (localStorage.getItem("guesses") != null) { if (localStorage.getItem("guesses") != null) {
console.log("local storage get!"); console.log("local storage get!");
gj = JSON.parse(localStorage.getItem("guesses")); gj = JSON.parse(localStorage.getItem("guesses"));
} }
console.log(gj);
if (current_guess != "" && flagSame == 0) { if (current_guess != "" && flagSame == 0) {
gj["Guesses"].push(current_guess); gj["Guesses"].push(current_guess);
console.warn(current_guess); console.warn(current_guess);
gj["Values"].push(<?php gj["Values"].push(<?php if ($_POST['mainInput'] != null) {
if ($_POST['mainInput'] != null) {
$inner_cg = htmlspecialchars($_POST['mainInput']); $inner_cg = htmlspecialchars($_POST['mainInput']);
} }
echo json_encode(comparePerson($inner_cg)); echo "'" . json_encode(comparePerson(reversePerson($inner_cg)), JSON_UNESCAPED_UNICODE) . "'"; ?>);
?>);
localStorage.setItem("guesses", JSON.stringify(gj)); localStorage.setItem("guesses", JSON.stringify(gj));
} }
if (gj["Guesses"].length > 0) {
const criterias = <?php echo json_encode(getAllCriterias(), JSON_UNESCAPED_UNICODE) ?>; const criterias = <?php echo json_encode(getAllCriterias(), JSON_UNESCAPED_UNICODE) ?>;
var crit_num = 0;
var true_num = 0;
var innerFlag = true;
if (gj["Guesses"].length > 0) {
point = document.getElementById("tahminler"); point = document.getElementById("tahminler");
const table = document.createElement("table"); const table = document.createElement("table");
const tr = document.createElement("tr"); const tr = document.createElement("tr");
table.style.width = "100%"; table.classList.add("guess-table");
// tr.style.display = "flex"; tr.classList.add("guess-tr");
tr.style.textAlign = "center"; table.appendChild(tr);
tr.style.justifyContent = "space-evenly";
tr.style.border = "red 1px solid";
table.appendChild(tr)
point.appendChild(table); point.appendChild(table);
for (const key in criterias) { for (const key in criterias) {
const th = document.createElement("th");
console.log(`${key} : ${criterias[key]}`) const th_text = document.createTextNode(criterias[key]);
th.classList.add("guess-th");
const crit_node = document.createElement("th"); th.appendChild(th_text);
const crit_text_node = document.createTextNode(criterias[key]); tr.appendChild(th);
crit_node.style.border = "aliceblue 1px solid";
crit_node.appendChild(crit_text_node);
tr.appendChild(crit_node);
} }
for (let i = gj["Guesses"].length - 1; i >= 0; i--) { for (let i = gj["Guesses"].length - 1; i >= 0; i--) {
// revit = gj["Guesses"].length - i - 1;
const tr = document.createElement("tr");
tr.classList.add("guess-tr");
table.appendChild(tr);
revit = gj["Guesses"].length - i - 1; indata = JSON.parse(gj["Values"][i]);
console.warn(revit); console.warn(indata);
for (const key in criterias) {
console.log(gj["Values"][revit]); if (innerFlag) crit_num++;
const td = document.createElement("td");
const element = gj["Guesses"][i]; const td_text = document.createTextNode(indata[key][1]);
point = document.getElementById("tahminler"); if (key != "isim_soyisim") {
const node = document.createElement("p"); switch (indata[key][0]) {
const textnode = document.createTextNode(element); case 0:
node.appendChild(textnode); td.classList.add("type0");
point.appendChild(node); break;
case 1:
td.classList.add("type1");
break;
case 2:
td.classList.add("type2");
if (innerFlag) true_num++;
break;
case 10:
td.classList.add("type10");
break;
case 12:
td.classList.add("type12");
break;
} }
} }
td.classList.add("guess-td");
td.appendChild(td_text);
tr.appendChild(td);
}
innerFlag = false;
}
}
console.log(gj);
if (crit_num == (true_num + 1)) // +1 isim_soyisim sayılmadığı için
{
console.warn(crit_num, true_num);
document.getElementById("tebriks").style.display = "block";
document.getElementById("tebriks").innerHTML = "Tebrikler, günün şanslı kişisini buldun!"
localStorage.setItem("win", "winned");
}
// NOTICES
notices = JSON.parse('<?php echo json_encode(getAllNotices(), JSON_UNESCAPED_UNICODE); ?>');
tmpflag = true;
notic = document.getElementById("notices");
if (notices.length > 1) {
notic.style.marginTop = "auto";
document.getElementById("sorumli").style.marginTop = "1px";
}
notices.forEach(element => {
if (tmpflag == true) {
tmpflag = false;
} else {
innot = document.createElement("p");
innot.classList.add("innot");
innot_text = document.createTextNode(element);
innot.appendChild(innot_text);
notic.appendChild(innot);
}
});
</script> </script>
<script> <script>
// UPDATES // UPDATES
@ -261,7 +328,9 @@
}); });
} }
autocomplete(document.getElementById("mainInput"), persons); const persons2 = <?php echo json_encode(getAllPersonNames(), JSON_UNESCAPED_UNICODE) ?>;
autocomplete(document.getElementById("mainInput"), persons2);
</script> </script>
</html> </html>

View file

@ -60,14 +60,20 @@ function getAllPersonNames()
array_push($arr, $d["isim_soyisim"]); array_push($arr, $d["isim_soyisim"]);
} }
return $arr; return $arr;
} }
function getAllCriterias() { function getAllCriterias()
{
$data = parseTOML()["public"]; $data = parseTOML()["public"];
return $data["gozukecek_kriterler"]; return $data["gozukecek_kriterler"];
} }
function getAllNotices()
{
$data = parseTOML()["public"];
return $data["kullanici_notlari"];
}
# send data update date and latest person update date # send data update date and latest person update date
function sendDataDate() function sendDataDate()
{ {
@ -76,19 +82,29 @@ function sendDataDate()
date_default_timezone_set('Europe/Istanbul'); date_default_timezone_set('Europe/Istanbul');
setlocale(LC_ALL, 'tr_TR'); setlocale(LC_ALL, 'tr_TR');
$filename="data.toml"; $filename = "data.toml";
if (file_exists(__DIR__ . "/../" . $filename)) { if (file_exists(__DIR__ . "/../" . $filename)) {
$arr[0] = date("d/m/Y H:i:s", filemtime(__DIR__ . "/../" . $filename)); $arr[0] = date("d/m/Y H:i:s", filemtime(__DIR__ . "/../" . $filename));
} }
$filename="todays.php"; $filename = "todays.php";
if (file_exists($filename)) { if (file_exists(__DIR__ . "/" . $filename)) {
$arr[1] = date("d/m/Y H:i:s", filemtime($filename)); $arr[1] = date("d/m/Y H:i:s", filemtime(__DIR__ . "/" . $filename));
} }
return $arr; return $arr;
} }
# Aliberk Sandıı -> aliberk_sandikci24
function reversePerson($str)
{
$data = parseTOML()["data"];
foreach ($data as $key => $value) {
if ($value["isim_soyisim"] == $str) {
return $key;
}
}
}
# compare a person with todays person, returns equalities (0-red, 1-orange, 2-green, 10-orange(küçük), 12-orange(büyük)) # compare a person with todays person, returns equalities (0-red, 1-orange, 2-green, 10-orange(küçük), 12-orange(büyük))
function comparePerson($person) function comparePerson($person)
@ -102,13 +118,13 @@ function comparePerson($person)
$curCrit = array_keys($kriterler)[$i]; $curCrit = array_keys($kriterler)[$i];
switch (array_values($kriterler)[$i]) { switch (array_values($kriterler)[$i]) {
case 'comp': case 'comp':
$RESULT[$curCrit] = compareCOMP($statGuess[$curCrit], $statTodays[$curCrit]); $RESULT[$curCrit] = [compareCOMP($statGuess[$curCrit], $statTodays[$curCrit]), $statGuess[$curCrit]];
break; break;
case 'arr': case 'arr':
$RESULT[$curCrit] = compareARR($statGuess[$curCrit], $statTodays[$curCrit], $curCrit); $RESULT[$curCrit] = [compareARR($statGuess[$curCrit], $statTodays[$curCrit], $curCrit), $statGuess[$curCrit]];
break; break;
default: default:
$RESULT[$curCrit] = compareEQ($statGuess[$curCrit], $statTodays[$curCrit]); $RESULT[$curCrit] = [compareEQ($statGuess[$curCrit], $statTodays[$curCrit]), $statGuess[$curCrit]];
break; break;
} }
} }