From b32337603bc3c14aea683406e75a44497d7881f4 Mon Sep 17 00:00:00 2001 From: asandikci Date: Sun, 7 Jan 2024 03:27:44 +0300 Subject: [PATCH] server update --- assets/css/yurdle.css | 72 +++++++++++++++++++++ buildzip.sh | 2 + dockerserver.sh | 12 ++-- index.php | 145 +++++++++++++++++++++++++++++++----------- src/server.php | 36 ++++++++--- 5 files changed, 214 insertions(+), 53 deletions(-) create mode 100644 assets/css/yurdle.css diff --git a/assets/css/yurdle.css b/assets/css/yurdle.css new file mode 100644 index 0000000..7705260 --- /dev/null +++ b/assets/css/yurdle.css @@ -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: "👆" +} \ No newline at end of file diff --git a/buildzip.sh b/buildzip.sh index ef06e40..e38299b 100755 --- a/buildzip.sh +++ b/buildzip.sh @@ -2,6 +2,8 @@ rm -rf build/ mkdir build +composer update +composer install cp -r ./* build/ cp -r ../YurdleBackend/* build/ cd build/ || exit diff --git a/dockerserver.sh b/dockerserver.sh index aa67773..469d46f 100755 --- a/dockerserver.sh +++ b/dockerserver.sh @@ -11,8 +11,8 @@ SCRIPT_NAME="dockerserver.sh" # name of the *this* file SCRIPT_DIR="Yurdle" # containing directory of the *this* file BUILD_DIR="." # build results of local source code (insert a dot (.) if you do not need to build your application) # DATABASE_TYPE="postgresql" # database type, either mysql or postgresql -MAIN_NAME="yurdle" # main program name -PORT1="8000" # TODO what is the difference between 8000 and 80 +MAIN_NAME="yurdle" # main program name +PORT1="8000" # TODO what is the difference between 8000 and 80 PORT2="80" WEB_ROOT_DIR="/usr/share/nginx/html/" # public web root dir @@ -217,8 +217,10 @@ _folder_permissions() { useradd -g $MAIN_NAME $MAIN_NAME cd $WEB_ROOT_DIR || exit chown $MAIN_NAME:nginx -R . - cd $WEB_SERVER_DIR || exit - chown $MAIN_NAME:nginx -R . + if [[ $SECRET_SERVER == "true" ]]; then + cd $WEB_SERVER_DIR || exit + chown $MAIN_NAME:nginx -R . + fi } if [[ $# -eq 0 ]]; then @@ -293,7 +295,7 @@ elif [[ $1 == "docker" ]]; then cp -r /server/$BUILD_DIR/* $WEB_SERVER_DIR/ fi - apt install php php-fpm php-cli composer -y + apt install php php-fpm php-cli -y locale-gen tr_TR # _setup_database diff --git a/index.php b/index.php index 8ac60d5..1ea4d22 100644 --- a/index.php +++ b/index.php @@ -9,6 +9,7 @@ + Yurdle | İFL @@ -20,15 +21,26 @@
-
+
-
+
-
Veri Sorumlusu: Ömer Arda Muratoğlu.
Her türlü kaldırılmasını, eklenmesini ve/veya değiştirilmesi istediğiniz veriler için kendisi ile iletişime geçiniz !
+
+ + +
+ +
+ +
+
+
Veri Sorumlusu: Ömer Arda Muratoğlu
Her türlü kaldırılmasını, eklenmesini ve/veya değiştirilmesi istediğiniz veriler için kendisi ile iletişime geçiniz !
+
Son veri güncelleme:
@@ -47,6 +59,16 @@ 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 date = new Date(); if (localStorage.getItem("latest_visit") === null) { @@ -84,67 +106,112 @@ } - var gj = JSON.parse('{"Guesses":[], "Values":[]}'); // guess json if (localStorage.getItem("guesses") != null) { console.log("local storage get!"); gj = JSON.parse(localStorage.getItem("guesses")); } - console.log(gj); if (current_guess != "" && flagSame == 0) { gj["Guesses"].push(current_guess); console.warn(current_guess); - gj["Values"].push(); + echo "'" . json_encode(comparePerson(reversePerson($inner_cg)), JSON_UNESCAPED_UNICODE) . "'"; ?>); localStorage.setItem("guesses", JSON.stringify(gj)); } - + const criterias = ; + var crit_num = 0; + var true_num = 0; + var innerFlag = true; if (gj["Guesses"].length > 0) { - const criterias = ; point = document.getElementById("tahminler"); const table = document.createElement("table"); const tr = document.createElement("tr"); - table.style.width = "100%"; - // tr.style.display = "flex"; - tr.style.textAlign = "center"; - tr.style.justifyContent = "space-evenly"; - tr.style.border = "red 1px solid"; - - table.appendChild(tr) + table.classList.add("guess-table"); + tr.classList.add("guess-tr"); + table.appendChild(tr); point.appendChild(table); for (const key in criterias) { - - console.log(`${key} : ${criterias[key]}`) - - const crit_node = document.createElement("th"); - const crit_text_node = document.createTextNode(criterias[key]); - crit_node.style.border = "aliceblue 1px solid"; - crit_node.appendChild(crit_text_node); - tr.appendChild(crit_node); + const th = document.createElement("th"); + const th_text = document.createTextNode(criterias[key]); + th.classList.add("guess-th"); + th.appendChild(th_text); + tr.appendChild(th); } 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; - console.warn(revit); - - console.log(gj["Values"][revit]); - - const element = gj["Guesses"][i]; - point = document.getElementById("tahminler"); - const node = document.createElement("p"); - const textnode = document.createTextNode(element); - node.appendChild(textnode); - point.appendChild(node); + indata = JSON.parse(gj["Values"][i]); + console.warn(indata); + for (const key in criterias) { + if (innerFlag) crit_num++; + const td = document.createElement("td"); + const td_text = document.createTextNode(indata[key][1]); + if (key != "isim_soyisim") { + switch (indata[key][0]) { + case 0: + td.classList.add("type0"); + 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(''); + 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); + } + }); \ No newline at end of file diff --git a/src/server.php b/src/server.php index d247944..57545b8 100644 --- a/src/server.php +++ b/src/server.php @@ -60,14 +60,20 @@ function getAllPersonNames() array_push($arr, $d["isim_soyisim"]); } return $arr; - } -function getAllCriterias() { +function getAllCriterias() +{ $data = parseTOML()["public"]; return $data["gozukecek_kriterler"]; } +function getAllNotices() +{ + $data = parseTOML()["public"]; + return $data["kullanici_notlari"]; +} + # send data update date and latest person update date function sendDataDate() { @@ -76,19 +82,29 @@ function sendDataDate() date_default_timezone_set('Europe/Istanbul'); setlocale(LC_ALL, 'tr_TR'); - $filename="data.toml"; + $filename = "data.toml"; if (file_exists(__DIR__ . "/../" . $filename)) { $arr[0] = date("d/m/Y H:i:s", filemtime(__DIR__ . "/../" . $filename)); } - $filename="todays.php"; - if (file_exists($filename)) { - $arr[1] = date("d/m/Y H:i:s", filemtime($filename)); + $filename = "todays.php"; + if (file_exists(__DIR__ . "/" . $filename)) { + $arr[1] = date("d/m/Y H:i:s", filemtime(__DIR__ . "/" . $filename)); } - + return $arr; } +# Aliberk Sandıkçı -> 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)) function comparePerson($person) @@ -102,13 +118,13 @@ function comparePerson($person) $curCrit = array_keys($kriterler)[$i]; switch (array_values($kriterler)[$i]) { case 'comp': - $RESULT[$curCrit] = compareCOMP($statGuess[$curCrit], $statTodays[$curCrit]); + $RESULT[$curCrit] = [compareCOMP($statGuess[$curCrit], $statTodays[$curCrit]), $statGuess[$curCrit]]; break; case 'arr': - $RESULT[$curCrit] = compareARR($statGuess[$curCrit], $statTodays[$curCrit], $curCrit); + $RESULT[$curCrit] = [compareARR($statGuess[$curCrit], $statTodays[$curCrit], $curCrit), $statGuess[$curCrit]]; break; default: - $RESULT[$curCrit] = compareEQ($statGuess[$curCrit], $statTodays[$curCrit]); + $RESULT[$curCrit] = [compareEQ($statGuess[$curCrit], $statTodays[$curCrit]), $statGuess[$curCrit]]; break; } }