From 3d819798dd1daac8fa3318ce6dcec2c63968cde4 Mon Sep 17 00:00:00 2001 From: asandikci Date: Sun, 7 Jan 2024 15:35:18 +0300 Subject: [PATCH] update --- .gitignore | 3 ++- assets/css/yurdle.css | 46 +++++++++++++++++++++++++++++++-- index.php | 58 +++++++++++++++++++++++++++++++++++++++-- src/server.php | 60 +++++++++++++++++-------------------------- src/todays.php | 3 +-- 5 files changed, 126 insertions(+), 44 deletions(-) diff --git a/.gitignore b/.gitignore index 381ce24..6a7dfcc 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ build/* *.tar.gz *.zip /vendor/ -config.php \ No newline at end of file +config.php +data.toml \ No newline at end of file diff --git a/assets/css/yurdle.css b/assets/css/yurdle.css index 7705260..da8efe3 100644 --- a/assets/css/yurdle.css +++ b/assets/css/yurdle.css @@ -27,8 +27,6 @@ } } -.guess-tr {} - .guess-th { border: aliceblue 3px solid; } @@ -69,4 +67,48 @@ .type12::after { content: "👆" +} + + +/* */ +/* AUTOCOMPLETE */ +/* */ + +.autocomplete { + /*the container must be positioned relative:*/ + position: relative; + display: inline-block; + box-sizing: border-box; +} + +.autocomplete-items { + box-sizing: border-box; + position: absolute; + border: 2px solid #10161d; + border-bottom: none; + border-top: none; + z-index: 99; + /*position the autocomplete items to be the same width as the container:*/ + top: 100%; + left: 0; + right: 0; +} + +.autocomplete-items div { + padding: 10px; + cursor: pointer; + background-color: #96939B; + border-bottom: 1px solid #10161d; +} + +.autocomplete-items div:hover { + /*when hovering an item:*/ + background-color: #00ADB5; + color: #e8e8e8; +} + +.autocomplete-active { + /*when navigating through the items using the arrow keys:*/ + background-color: #00ADB5 !important; + color: #e8e8e8; } \ No newline at end of file diff --git a/index.php b/index.php index 8f7e2ac..9a2cb8a 100644 --- a/index.php +++ b/index.php @@ -25,9 +25,9 @@ min-height: 100vh;">
-
+
-
+
@@ -38,6 +38,8 @@
+ +

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 !

@@ -54,6 +56,52 @@ + + \ No newline at end of file diff --git a/src/server.php b/src/server.php index 59a8cdf..e96a5f2 100644 --- a/src/server.php +++ b/src/server.php @@ -9,14 +9,11 @@ require __DIR__ . '/../vendor/autoload.php'; $parser = new Toml(); $dock_local_test = 1; -# Fetch remote data each 1 hour +# Fetch Remote data and update data.toml (running each 10 min with cronjob) function updateRemoteData() { - # PREREQUIRITIES Create a cronjob or a systemd service for update it regularly ! - - # GET FROM GIT WITH ACCESS TOKEN AND SAVE TO data.toml - global $DATAACCESS_TOKEN; + global $APP_NAME; $string = file_get_contents("https://git.aliberksandikci.com.tr/api/v1/repos/ifl/YurdleBackend/raw/data.toml?access_token=" . $DATAACCESS_TOKEN); if ($string === FALSE) { echo "Could not read the file."; @@ -24,47 +21,40 @@ function updateRemoteData() $file = __DIR__ . "/../data.toml"; file_put_contents($file, $string, LOCK_EX); } + chmod("$file", 0700); + chown("$file", $APP_NAME); - # REVIEW MAKE SURE FILE IS CHMOD 600 AND NOT ACCESSIBLE FROM USERSIDE !!! - - - parseTOML(); # parse again after update + parseTOML(); // not necessary } -# Choose the todays person, everyday TSI 03:00 +# Choose the todays person (running each day with cronjob) function chooseTodayPerson() { - # PREREQUIRIITES with cronjob or systemd, run this function everyday TSI 03.00 + global $APP_NAME; + $data = parseTOML()["data"]; - # parse toml + $personArr = array(); + foreach ($data as $key => $value) { + array_push($personArr, $key); + } + print_r($personArr); + srand(); + $random_number = random_int(0, count($personArr) - 1); + $choosen = $personArr[$random_number]; - # get users array length + // TODO control each person if already choosed recently? (make all persons avaliable AFTER all of them choosed ) - # get a random number - - # make this person todays person, change $TODAYS_PERSON variable in today.php + $string = " "Aliberk Sandıkçı - - // APPROACH 1: (needs public-> users array) - // $users = parseTOML()["public"]["users"]; - // $arr = array(); - // foreach ($users as $user) { - // array_push($arr, parseTOML()["data"][$user]["isim_soyisim"]); - // } - // return $arr; - - // APPROACH 2: $data = parseTOML()["data"]; $arr = array(); foreach ($data as $d) { @@ -102,7 +92,6 @@ function sendDataDate() $arr[1] = date("d/m/Y H:i:s", filemtime(__DIR__ . "/" . $filename)); } - return $arr; } @@ -178,7 +167,7 @@ function compareARR($guess, $todays, $krit) if ($equalNum == 0) { return 0; - } else if ($equalNum == count($todays)) { + } else if ($equalNum == count($todays) && $equalNum == count($guess)) { return 2; } else if ($equalNum >= 1) { return 1; @@ -200,6 +189,3 @@ function parseTOML() $array = $parser::ParseFile(__DIR__ . "/../data.toml"); return $array; } - -updateRemoteData(); -comparePerson('aliberk_sandikci24'); diff --git a/src/todays.php b/src/todays.php index db8955d..f0d7214 100644 --- a/src/todays.php +++ b/src/todays.php @@ -1,2 +1 @@ -