diff --git a/software/v0.0.1/web/bets.php b/software/v0.0.1/web/bets.php index e480f42..8255eb5 100644 --- a/software/v0.0.1/web/bets.php +++ b/software/v0.0.1/web/bets.php @@ -1 +1,128 @@ -prepare('INSERT INTO bets(status,option1,option2,created_ts) VALUES(?,?,?,?)'); $st->execute(['open',$o1,$o2,gmdate('c')]); $msg='Bet åbnet.'; } } if(isset($_POST['close'])){ $db->exec("UPDATE bets SET status='closed', close_ts='".gmdate('c')."' WHERE status='open'"); $msg='Bet lukket.'; } if(isset($_POST['resolve'])){ $win=(int)($_POST['winner']??1); $last=$db->query("SELECT * FROM bets WHERE status='closed' ORDER BY id DESC LIMIT 1")->fetch(PDO::FETCH_ASSOC); if($last){ $st=$db->prepare('SELECT user_login, amount FROM bet_entries WHERE bet_id=? AND option=?'); $st->execute([$last['id'],$win]); $wins=$st->fetchAll(PDO::FETCH_ASSOC); foreach($wins as $w){ $db->prepare('INSERT INTO points(user_login,display_name,points) VALUES(?,?,?) ON CONFLICT(user_login) DO UPDATE SET points=points+excluded.points')->execute([$w['user_login'],$w['user_login'],(int)$w['amount']*2]); } $db->prepare('UPDATE bets SET status="resolved", resolved_option=? WHERE id=?')->execute([$win,$last['id']]); $msg='Bet resolved, vinder: option '.$win; } } } $last=$db->query('SELECT * FROM bets ORDER BY id DESC LIMIT 1')->fetch(PDO::FETCH_ASSOC); $entries=$last?$db->query('SELECT * FROM bet_entries WHERE bet_id='.(int)$last['id'])->fetchAll(PDO::FETCH_ASSOC):[]; ?>Bets

💸 Bets

← Tilbage



Status: – # ()

Indskud

'; } ?>
BrugerBeløbOption
@'.htmlspecialchars($e['user_login']).''.(int)$e['amount'].''.(int)$e['option'].'
\ No newline at end of file +prepare('INSERT INTO bets (status, option1, option2, created_ts) VALUES (?, ?, ?, ?)'); + $st->execute(['open', $o1, $o2, gmdate('c')]); + $msg = 'Bet åbnet.'; + } + } + + // Luk indskud + if (isset($_POST['close'])) { + $db->exec("UPDATE bets SET status='closed', close_ts='" . gmdate('c') . "' WHERE status='open'"); + $msg = 'Bet lukket.'; + } + + // Afslut og udbetal + if (isset($_POST['resolve'])) { + $win = (int)($_POST['winner'] ?? 1); + $win = ($win === 2) ? 2 : 1; // clamp til 1/2 + + $last = $db->query("SELECT * FROM bets WHERE status='closed' ORDER BY id DESC LIMIT 1") + ->fetch(PDO::FETCH_ASSOC); + + if ($last) { + // Find vindere + $st = $db->prepare('SELECT user_login, amount FROM bet_entries WHERE bet_id = ? AND option = ?'); + $st->execute([$last['id'], $win]); + $wins = $st->fetchAll(PDO::FETCH_ASSOC); + + // Udbetal 2x indsats (UPSERT på points-tabellen) + foreach ($wins as $w) { + $db->prepare( + 'INSERT INTO points (user_login, display_name, points) + VALUES (?, ?, ?) + ON CONFLICT(user_login) DO UPDATE SET points = points + excluded.points' + )->execute([$w['user_login'], $w['user_login'], (int)$w['amount'] * 2]); + } + + // Marker bet som resolved (STRINGSKONSTANT med enkeltanførselstegn) + $db->prepare("UPDATE bets SET status='resolved', resolved_option=? WHERE id=?") + ->execute([$win, $last['id']]); + + $msg = 'Bet resolved, vinder: option ' . $win; + } + } +} + +$last = $db->query('SELECT * FROM bets ORDER BY id DESC LIMIT 1')->fetch(PDO::FETCH_ASSOC); +$entries = $last ? $db->query('SELECT * FROM bet_entries WHERE bet_id=' . (int)$last['id'])->fetchAll(PDO::FETCH_ASSOC) : []; +?> + + + + + Bets + + + +
+
+

💸 Bets

+

← Tilbage

+ + +

+ + +
+ +
+ +
+ + + + + + +
+ + +

+ Status: + + – # + () +

+ +

Indskud

+ + + + + + + + + + + + + +
BrugerBeløbOption
@
+ +
+
+ + diff --git a/software/v0.0.1/web/commands.php b/software/v0.0.1/web/commands.php index 4eb1c83..52e38c4 100644 --- a/software/v0.0.1/web/commands.php +++ b/software/v0.0.1/web/commands.php @@ -1 +1,131 @@ -Kommandoer

Bot-kommandoer

← Tilbage📖 Hjælp



$v): ?>
!kommandoSvarHandling
\ No newline at end of file + + + + + + Kommandoer + + + + +
+
+

Bot-kommandoer

+

+ ← Tilbage + 📖 Hjælp +

+ +
+ + + +
+ + +
+ + +
+ + + + + + + + + $v): ?> + + + + + + +
!kommandoSvarHandling
+
+ + + +
+ +
+ + + +
+ +
+ + + +
+
+ +
+
+ + diff --git a/software/v0.0.1/web/control.php b/software/v0.0.1/web/control.php index 8822c0f..340ff7c 100644 --- a/software/v0.0.1/web/control.php +++ b/software/v0.0.1/web/control.php @@ -1 +1,33 @@ -NUL 2>&1'); header('Location: index.php'); exit; } if($a==='stop'){ file_put_contents($stop,'1'); header('Location: index.php'); exit; } if($a==='restart'){ file_put_contents($stop,'1'); echo 'Genstarter...'; exit; } header('Location: index.php'); \ No newline at end of file +NUL 2>&1'); + } + + header('Location: index.php'); + exit; +} + +if ($action === 'stop') { + file_put_contents($stop, '1'); + header('Location: index.php'); + exit; +} + +if ($action === 'restart') { + file_put_contents($stop, '1'); + echo 'Genstarter...'; + exit; +} + +header('Location: index.php'); diff --git a/software/v0.0.1/web/login.php b/software/v0.0.1/web/login.php index 7eb8db2..ac2a142 100644 --- a/software/v0.0.1/web/login.php +++ b/software/v0.0.1/web/login.php @@ -55,17 +55,18 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { Login – Twitch PHP Bot - + +

🔐 Login

- + - +
diff --git a/software/v0.0.1/web/logo.png b/software/v0.0.1/web/logo.png new file mode 100644 index 0000000..bef7c63 Binary files /dev/null and b/software/v0.0.1/web/logo.png differ diff --git a/software/v0.0.1/web/style.css b/software/v0.0.1/web/style.css index 7554054..0f1da3e 100644 --- a/software/v0.0.1/web/style.css +++ b/software/v0.0.1/web/style.css @@ -133,3 +133,17 @@ td { .right { float: right; } +html { + height: 100%; + width: 100%; +} +#bg-image { + height: 100%; + width: 100%; + position: fixed; + background-image: url(logo.png); + background-position: center center; + background-repeat: no-repeat; + background-size: cover; + opacity: 0.3; +} \ No newline at end of file