File size: 50,822 Bytes
3a2e0ad | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tech Null Messenger</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.gradient-bg {
background: linear-gradient(135deg, #1e3a8a 0%, #0ea5e9 100%);
}
.chat-container {
height: calc(100vh - 200px);
}
.message-animation {
animation: fadeIn 0.3s ease-in-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.blink {
animation: blink 1s infinite;
}
@keyframes blink {
0% { opacity: 1; }
50% { opacity: 0.5; }
100% { opacity: 1; }
}
</style>
</head>
<body class="bg-gray-100 font-sans">
<div id="app" class="min-h-screen flex flex-col">
<!-- Header -->
<header class="gradient-bg text-white p-4 shadow-lg">
<div class="container mx-auto flex justify-between items-center">
<h1 class="text-2xl font-bold flex items-center">
<i class="fas fa-robot mr-2"></i> Tech Null
</h1>
<div id="auth-status" class="flex items-center space-x-4">
<span id="user-info" class="hidden">
<span id="username-display" class="font-semibold"></span>
<button id="logout-btn" class="ml-2 bg-red-500 hover:bg-red-600 text-white px-3 py-1 rounded text-sm">
<i class="fas fa-sign-out-alt mr-1"></i> Logout
</button>
</span>
</div>
</div>
</header>
<!-- Main Content -->
<main class="flex-grow container mx-auto p-4">
<!-- Auth Screens -->
<div id="auth-screens" class="max-w-md mx-auto">
<!-- Login Screen -->
<div id="login-screen" class="bg-white rounded-lg shadow-md p-6 mb-4">
<h2 class="text-xl font-bold mb-4 text-gray-800">Login</h2>
<div class="mb-4">
<label for="login-id" class="block text-gray-700 mb-2">ID</label>
<input type="number" id="login-id" class="w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div class="mb-4">
<label for="login-password" class="block text-gray-700 mb-2">Password</label>
<input type="password" id="login-password" class="w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<button id="login-btn" class="w-full bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded font-medium">
<i class="fas fa-sign-in-alt mr-2"></i> Login
</button>
<p class="text-center mt-4 text-gray-600">Don't have an account? <button id="show-register-btn" class="text-blue-500 hover:text-blue-700 font-medium">Register</button></p>
</div>
<!-- Register Screen -->
<div id="register-screen" class="bg-white rounded-lg shadow-md p-6 hidden">
<h2 class="text-xl font-bold mb-4 text-gray-800">Register</h2>
<div class="mb-4">
<label for="register-username" class="block text-gray-700 mb-2">Username (max 20 chars)</label>
<input type="text" id="register-username" maxlength="20" class="w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div class="mb-4">
<label for="register-password" class="block text-gray-700 mb-2">Password (max 20 chars)</label>
<input type="password" id="register-password" maxlength="20" class="w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<button id="register-btn" class="w-full bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded font-medium">
<i class="fas fa-user-plus mr-2"></i> Register
</button>
<p class="text-center mt-4 text-gray-600">Already have an account? <button id="show-login-btn" class="text-blue-500 hover:text-blue-700 font-medium">Login</button></p>
</div>
</div>
<!-- Chat Screen -->
<div id="chat-screen" class="hidden">
<div class="flex flex-col lg:flex-row gap-4">
<!-- Chat Area -->
<div class="flex-grow">
<div class="bg-white rounded-lg shadow-md overflow-hidden">
<div class="p-4 border-b border-gray-200 bg-gray-50">
<h2 class="text-xl font-bold text-gray-800">Global Chat</h2>
<div id="message-stats" class="text-sm text-gray-600 mt-1">
Messages: <span id="message-count">0</span> • Users: <span id="user-count">1</span>
</div>
</div>
<div id="chat-messages" class="chat-container overflow-y-auto p-4 space-y-4">
<!-- Messages will appear here -->
</div>
<div class="p-4 border-t border-gray-200 bg-gray-50">
<div class="flex items-center">
<input type="text" id="message-input" maxlength="1000" placeholder="Type your message..." class="flex-grow px-3 py-2 border border-gray-300 rounded-l focus:outline-none focus:ring-2 focus:ring-blue-500">
<button id="send-btn" class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-r">
<i class="fas fa-paper-plane"></i>
</button>
</div>
<div id="message-counter" class="text-sm text-gray-600 mt-2">
Messages this hour: <span id="messages-sent">0</span>/<span id="message-limit">10</span>
</div>
</div>
</div>
</div>
<!-- User Panel -->
<div class="w-full lg:w-64">
<div class="bg-white rounded-lg shadow-md overflow-hidden">
<div class="p-4 border-b border-gray-200 bg-gray-50">
<h2 class="text-xl font-bold text-gray-800">User Panel</h2>
</div>
<div class="p-4 space-y-4">
<div>
<h3 class="font-semibold text-gray-700 mb-2">Account Info</h3>
<div class="text-sm text-gray-600 space-y-1">
<p>ID: <span id="user-id-display" class="font-medium"></span></p>
<p>Username: <span id="user-name-display" class="font-medium"></span></p>
<p>Registered: <span id="user-registered" class="font-medium"></span></p>
</div>
</div>
<div>
<h3 class="font-semibold text-gray-700 mb-2">Settings</h3>
<div class="space-y-2">
<button id="change-username-btn" class="w-full text-left bg-gray-100 hover:bg-gray-200 text-gray-800 px-3 py-2 rounded text-sm">
<i class="fas fa-user-edit mr-1"></i> Change Username
</button>
<button id="change-password-btn" class="w-full text-left bg-gray-100 hover:bg-gray-200 text-gray-800 px-3 py-2 rounded text-sm">
<i class="fas fa-key mr-1"></i> Change Password
</button>
</div>
</div>
<div id="admin-panel" class="hidden">
<h3 class="font-semibold text-gray-700 mb-2">Admin Panel</h3>
<div class="space-y-2">
<div class="flex items-center">
<input type="text" id="admin-command" placeholder="Enter command..." class="flex-grow px-2 py-1 text-sm border border-gray-300 rounded-l focus:outline-none focus:ring-1 focus:ring-blue-500">
<button id="execute-command-btn" class="bg-blue-500 hover:bg-blue-600 text-white px-2 py-1 rounded-r text-sm">
<i class="fas fa-terminal"></i>
</button>
</div>
<button id="help-btn" class="w-full text-left bg-gray-100 hover:bg-gray-200 text-gray-800 px-3 py-2 rounded text-sm">
<i class="fas fa-question-circle mr-1"></i> Show Help
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<!-- Modals -->
<!-- Change Username Modal -->
<div id="username-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50">
<div class="bg-white rounded-lg shadow-xl p-6 w-full max-w-md">
<h3 class="text-lg font-bold mb-4">Change Username</h3>
<div class="mb-4">
<label for="new-username" class="block text-gray-700 mb-2">New Username (max 20 chars)</label>
<input type="text" id="new-username" maxlength="20" class="w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div class="flex justify-end space-x-3">
<button id="cancel-username-btn" class="px-4 py-2 border border-gray-300 rounded text-gray-700 hover:bg-gray-100">Cancel</button>
<button id="save-username-btn" class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600">Save</button>
</div>
</div>
</div>
<!-- Change Password Modal -->
<div id="password-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50">
<div class="bg-white rounded-lg shadow-xl p-6 w-full max-w-md">
<h3 class="text-lg font-bold mb-4">Change Password</h3>
<div class="mb-4">
<label for="current-password" class="block text-gray-700 mb-2">Current Password</label>
<input type="password" id="current-password" class="w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div class="mb-4">
<label for="new-password" class="block text-gray-700 mb-2">New Password (max 20 chars)</label>
<input type="password" id="new-password" maxlength="20" class="w-full px-3 py-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div class="flex justify-end space-x-3">
<button id="cancel-password-btn" class="px-4 py-2 border border-gray-300 rounded text-gray-700 hover:bg-gray-100">Cancel</button>
<button id="save-password-btn" class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600">Save</button>
</div>
</div>
</div>
<!-- Admin Help Modal -->
<div id="help-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50">
<div class="bg-white rounded-lg shadow-xl p-6 w-full max-w-2xl max-h-[80vh] overflow-y-auto">
<h3 class="text-lg font-bold mb-4">Admin Commands Help</h3>
<div class="space-y-3 text-sm">
<div class="p-3 bg-gray-50 rounded">
<p class="font-semibold">/mute id x</p>
<p class="text-gray-600">Mute account by ID for x hours</p>
</div>
<div class="p-3 bg-gray-50 rounded">
<p class="font-semibold">/unmute id</p>
<p class="text-gray-600">Unmute account by ID</p>
</div>
<div class="p-3 bg-gray-50 rounded">
<p class="font-semibold">/del_m mid</p>
<p class="text-gray-600">Delete message by message ID</p>
</div>
<div class="p-3 bg-gray-50 rounded">
<p class="font-semibold">/del_um id</p>
<p class="text-gray-600">Delete all messages by user ID</p>
</div>
<div class="p-3 bg-gray-50 rounded">
<p class="font-semibold">/limit_m x</p>
<p class="text-gray-600">Set message limit per hour to x</p>
</div>
<div class="p-3 bg-gray-50 rounded">
<p class="font-semibold">/limit_reset</p>
<p class="text-gray-600">Reset message counters for all users</p>
</div>
<div class="p-3 bg-gray-50 rounded">
<p class="font-semibold">/vipe_chat</p>
<p class="text-gray-600">Delete all messages from chat</p>
</div>
<div class="p-3 bg-gray-50 rounded">
<p class="font-semibold">/vipe_all</p>
<p class="text-gray-600">Delete all messages and accounts (except ID 0)</p>
</div>
<div class="p-3 bg-gray-50 rounded">
<p class="font-semibold">/change_n id x</p>
<p class="text-gray-600">Change username of user ID to x</p>
</div>
<div class="p-3 bg-gray-50 rounded">
<p class="font-semibold">/change_p id x</p>
<p class="text-gray-600">Change password of user ID to x</p>
</div>
<div class="p-3 bg-gray-50 rounded">
<p class="font-semibold">/check_ip mid</p>
<p class="text-gray-600">Check IP of message by message ID</p>
</div>
<div class="p-3 bg-gray-50 rounded">
<p class="font-semibold">/mute_ip ip x</p>
<p class="text-gray-600">Mute IP address for x hours</p>
</div>
<div class="p-3 bg-gray-50 rounded">
<p class="font-semibold">/unmute_ip ip</p>
<p class="text-gray-600">Unmute IP address</p>
</div>
<div class="p-3 bg-gray-50 rounded">
<p class="font-semibold">/list</p>
<p class="text-gray-600">List all muted IPs/accounts</p>
</div>
<div class="p-3 bg-gray-50 rounded">
<p class="font-semibold">/help</p>
<p class="text-gray-600">Show this help</p>
</div>
</div>
<div class="mt-4 flex justify-end">
<button id="close-help-btn" class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600">Close</button>
</div>
</div>
</div>
<!-- Registration Success Modal -->
<div id="register-success-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50">
<div class="bg-white rounded-lg shadow-xl p-6 w-full max-w-md">
<h3 class="text-lg font-bold mb-4 text-green-600">Registration Successful!</h3>
<div class="mb-4">
<p class="text-gray-700">Your account has been created.</p>
<div class="mt-3 p-3 bg-gray-50 rounded">
<p class="font-semibold">ID: <span id="registered-id" class="font-normal"></span></p>
<p class="font-semibold">Username: <span id="registered-username" class="font-normal"></span></p>
</div>
<p class="mt-3 text-sm text-gray-600">Please remember your ID as you'll need it to login.</p>
</div>
<div class="flex justify-end">
<button id="ok-register-btn" class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600">OK</button>
</div>
</div>
</div>
</div>
<script>
// Data storage
const data = {
users: [
{
id: 0,
username: "Null",
password: "QWERTYnull123!",
registered: new Date().toISOString(),
ip: "127.0.0.1",
deviceId: "admin-device"
}
],
messages: [],
mutedUsers: {},
mutedIPs: {},
messageCounters: {},
deviceRegistrations: {},
messageLimit: 10,
nextMessageId: 1
};
// Simulate localStorage for demo purposes
function saveData() {
localStorage.setItem('techNullData', JSON.stringify(data));
}
function loadData() {
const savedData = localStorage.getItem('techNullData');
if (savedData) {
Object.assign(data, JSON.parse(savedData));
}
}
// Initialize
loadData();
// Current user state
let currentUser = null;
let currentIP = "127.0.0.1"; // In a real app, this would come from the server
let currentDeviceId = "demo-device"; // In a real app, generate a unique device ID
// DOM Elements
const loginScreen = document.getElementById('login-screen');
const registerScreen = document.getElementById('register-screen');
const chatScreen = document.getElementById('chat-screen');
const loginIdInput = document.getElementById('login-id');
const loginPasswordInput = document.getElementById('login-password');
const registerUsernameInput = document.getElementById('register-username');
const registerPasswordInput = document.getElementById('register-password');
const messageInput = document.getElementById('message-input');
const chatMessages = document.getElementById('chat-messages');
const userInfo = document.getElementById('user-info');
const usernameDisplay = document.getElementById('username-display');
const logoutBtn = document.getElementById('logout-btn');
const showRegisterBtn = document.getElementById('show-register-btn');
const showLoginBtn = document.getElementById('show-login-btn');
const loginBtn = document.getElementById('login-btn');
const registerBtn = document.getElementById('register-btn');
const sendBtn = document.getElementById('send-btn');
const userIdDisplay = document.getElementById('user-id-display');
const userNameDisplay = document.getElementById('user-name-display');
const userRegistered = document.getElementById('user-registered');
const adminPanel = document.getElementById('admin-panel');
const adminCommand = document.getElementById('admin-command');
const executeCommandBtn = document.getElementById('execute-command-btn');
const changeUsernameBtn = document.getElementById('change-username-btn');
const changePasswordBtn = document.getElementById('change-password-btn');
const usernameModal = document.getElementById('username-modal');
const newUsernameInput = document.getElementById('new-username');
const saveUsernameBtn = document.getElementById('save-username-btn');
const cancelUsernameBtn = document.getElementById('cancel-username-btn');
const passwordModal = document.getElementById('password-modal');
const currentPasswordInput = document.getElementById('current-password');
const newPasswordInput = document.getElementById('new-password');
const savePasswordBtn = document.getElementById('save-password-btn');
const cancelPasswordBtn = document.getElementById('cancel-password-btn');
const helpModal = document.getElementById('help-modal');
const helpBtn = document.getElementById('help-btn');
const closeHelpBtn = document.getElementById('close-help-btn');
const registerSuccessModal = document.getElementById('register-success-modal');
const registeredId = document.getElementById('registered-id');
const registeredUsername = document.getElementById('registered-username');
const okRegisterBtn = document.getElementById('ok-register-btn');
const messageCount = document.getElementById('message-count');
const userCount = document.getElementById('user-count');
const messagesSent = document.getElementById('messages-sent');
const messageLimit = document.getElementById('message-limit');
// Event Listeners
showRegisterBtn.addEventListener('click', () => {
loginScreen.classList.add('hidden');
registerScreen.classList.remove('hidden');
});
showLoginBtn.addEventListener('click', () => {
registerScreen.classList.add('hidden');
loginScreen.classList.remove('hidden');
});
loginBtn.addEventListener('click', handleLogin);
registerBtn.addEventListener('click', handleRegister);
logoutBtn.addEventListener('click', handleLogout);
sendBtn.addEventListener('click', sendMessage);
messageInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
sendMessage();
}
});
changeUsernameBtn.addEventListener('click', () => {
newUsernameInput.value = currentUser.username;
usernameModal.classList.remove('hidden');
});
changePasswordBtn.addEventListener('click', () => {
currentPasswordInput.value = '';
newPasswordInput.value = '';
passwordModal.classList.remove('hidden');
});
saveUsernameBtn.addEventListener('click', saveUsername);
cancelUsernameBtn.addEventListener('click', () => usernameModal.classList.add('hidden'));
savePasswordBtn.addEventListener('click', savePassword);
cancelPasswordBtn.addEventListener('click', () => passwordModal.classList.add('hidden'));
executeCommandBtn.addEventListener('click', executeAdminCommand);
adminCommand.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
executeAdminCommand();
}
});
helpBtn.addEventListener('click', () => helpModal.classList.remove('hidden'));
closeHelpBtn.addEventListener('click', () => helpModal.classList.add('hidden'));
okRegisterBtn.addEventListener('click', () => {
registerSuccessModal.classList.add('hidden');
registerScreen.classList.add('hidden');
loginScreen.classList.remove('hidden');
});
// Functions
function handleLogin() {
const id = parseInt(loginIdInput.value);
const password = loginPasswordInput.value;
if (isNaN(id)) {
showAlert('Please enter a valid ID');
return;
}
if (!password) {
showAlert('Please enter your password');
return;
}
const user = data.users.find(u => u.id === id);
if (!user) {
showAlert('User not found');
return;
}
// Check if user is muted
if (data.mutedUsers[user.id] && new Date(data.mutedUsers[user.id]) > new Date()) {
const muteTime = new Date(data.mutedUsers[user.id]);
showAlert(`You are muted until ${muteTime.toLocaleString()}`);
return;
}
// Check if IP is muted
if (data.mutedIPs[currentIP] && new Date(data.mutedIPs[currentIP]) > new Date()) {
const muteTime = new Date(data.mutedIPs[currentIP]);
showAlert(`Your IP is muted until ${muteTime.toLocaleString()}`);
return;
}
if (user.password !== password) {
showAlert('Incorrect password');
return;
}
currentUser = user;
loginSuccess();
}
function handleRegister() {
const username = registerUsernameInput.value.trim();
const password = registerPasswordInput.value;
if (!username) {
showAlert('Please enter a username');
return;
}
if (username.length > 20) {
showAlert('Username must be 20 characters or less');
return;
}
if (!password) {
showAlert('Please enter a password');
return;
}
if (password.length > 20) {
showAlert('Password must be 20 characters or less');
return;
}
// Check device registration limit (2 per month)
const now = new Date();
const month = now.getFullYear() + '-' + now.getMonth();
if (!data.deviceRegistrations[currentDeviceId]) {
data.deviceRegistrations[currentDeviceId] = {};
}
if (!data.deviceRegistrations[currentDeviceId][month]) {
data.deviceRegistrations[currentDeviceId][month] = 0;
}
if (data.deviceRegistrations[currentDeviceId][month] >= 2) {
showAlert('You can only create 2 accounts per month from this device');
return;
}
// Create new user
const newId = data.users.length > 0 ? Math.max(...data.users.map(u => u.id)) + 1 : 1;
const newUser = {
id: newId,
username,
password,
registered: new Date().toISOString(),
ip: currentIP,
deviceId: currentDeviceId
};
data.users.push(newUser);
data.deviceRegistrations[currentDeviceId][month]++;
saveData();
// Show success modal
registeredId.textContent = newId;
registeredUsername.textContent = username;
registerSuccessModal.classList.remove('hidden');
}
function loginSuccess() {
loginScreen.classList.add('hidden');
registerScreen.classList.add('hidden');
chatScreen.classList.remove('hidden');
usernameDisplay.textContent = currentUser.username;
userInfo.classList.remove('hidden');
userIdDisplay.textContent = currentUser.id;
userNameDisplay.textContent = currentUser.username;
userRegistered.textContent = new Date(currentUser.registered).toLocaleString();
// Show admin panel if admin
if (currentUser.id === 0) {
adminPanel.classList.remove('hidden');
} else {
adminPanel.classList.add('hidden');
}
// Initialize message counter
if (!data.messageCounters[currentUser.id]) {
data.messageCounters[currentUser.id] = {
count: 0,
lastReset: new Date().toISOString()
};
}
// Update UI
updateMessageCounter();
updateStats();
loadMessages();
}
function handleLogout() {
currentUser = null;
chatScreen.classList.add('hidden');
loginScreen.classList.remove('hidden');
userInfo.classList.add('hidden');
loginIdInput.value = '';
loginPasswordInput.value = '';
messageInput.value = '';
}
function sendMessage() {
if (!currentUser) return;
const text = messageInput.value.trim();
if (!text) return;
// Check if user is muted
if (data.mutedUsers[currentUser.id] && new Date(data.mutedUsers[currentUser.id]) > new Date()) {
const muteTime = new Date(data.mutedUsers[currentUser.id]);
showAlert(`You are muted until ${muteTime.toLocaleString()}`);
return;
}
// Check if IP is muted
if (data.mutedIPs[currentIP] && new Date(data.mutedIPs[currentIP]) > new Date()) {
const muteTime = new Date(data.mutedIPs[currentIP]);
showAlert(`Your IP is muted until ${muteTime.toLocaleString()}`);
return;
}
// Check message limit
const now = new Date();
const lastReset = new Date(data.messageCounters[currentUser.id].lastReset);
const hoursDiff = Math.abs(now - lastReset) / 36e5;
if (hoursDiff >= 1) {
// Reset counter if more than an hour has passed
data.messageCounters[currentUser.id] = {
count: 0,
lastReset: now.toISOString()
};
}
if (data.messageCounters[currentUser.id].count >= data.messageLimit) {
showAlert(`You can only send ${data.messageLimit} messages per hour`);
return;
}
// Create message
const message = {
id: data.nextMessageId++,
userId: currentUser.id,
username: currentUser.username,
text,
timestamp: now.toISOString(),
ip: currentIP
};
data.messages.push(message);
data.messageCounters[currentUser.id].count++;
saveData();
// Update UI
messageInput.value = '';
appendMessage(message);
updateMessageCounter();
updateStats();
}
function loadMessages() {
chatMessages.innerHTML = '';
data.messages.forEach(message => {
appendMessage(message);
});
}
function appendMessage(message) {
const user = data.users.find(u => u.id === message.userId);
if (!user) return;
const messageDiv = document.createElement('div');
messageDiv.className = 'message-animation bg-gray-50 p-3 rounded-lg border border-gray-200';
const header = document.createElement('div');
header.className = 'flex justify-between items-center text-sm mb-1';
const userInfo = document.createElement('span');
userInfo.className = 'font-semibold';
userInfo.textContent = `${user.username} / ${user.id} / m${message.id}`;
const time = document.createElement('span');
time.className = 'text-gray-500';
time.textContent = new Date(message.timestamp).toLocaleTimeString();
header.appendChild(userInfo);
header.appendChild(time);
const content = document.createElement('div');
content.className = 'text-gray-800';
content.textContent = message.text;
messageDiv.appendChild(header);
messageDiv.appendChild(content);
chatMessages.appendChild(messageDiv);
chatMessages.scrollTop = chatMessages.scrollHeight;
}
function updateMessageCounter() {
if (!currentUser) return;
const now = new Date();
const lastReset = new Date(data.messageCounters[currentUser.id].lastReset);
const hoursDiff = Math.abs(now - lastReset) / 36e5;
if (hoursDiff >= 1) {
// Reset counter if more than an hour has passed
data.messageCounters[currentUser.id] = {
count: 0,
lastReset: now.toISOString()
};
saveData();
}
messagesSent.textContent = data.messageCounters[currentUser.id].count;
messageLimit.textContent = data.messageLimit;
}
function updateStats() {
messageCount.textContent = data.messages.length;
userCount.textContent = data.users.length;
}
function saveUsername() {
const newUsername = newUsernameInput.value.trim();
if (!newUsername) {
showAlert('Please enter a username');
return;
}
if (newUsername.length > 20) {
showAlert('Username must be 20 characters or less');
return;
}
currentUser.username = newUsername;
usernameDisplay.textContent = newUsername;
userNameDisplay.textContent = newUsername;
// Update all messages with new username
data.messages.forEach(message => {
if (message.userId === currentUser.id) {
message.username = newUsername;
}
});
saveData();
usernameModal.classList.add('hidden');
loadMessages();
showAlert('Username updated successfully');
}
function savePassword() {
const currentPassword = currentPasswordInput.value;
const newPassword = newPasswordInput.value;
if (!currentPassword) {
showAlert('Please enter your current password');
return;
}
if (currentUser.password !== currentPassword) {
showAlert('Current password is incorrect');
return;
}
if (!newPassword) {
showAlert('Please enter a new password');
return;
}
if (newPassword.length > 20) {
showAlert('Password must be 20 characters or less');
return;
}
currentUser.password = newPassword;
saveData();
passwordModal.classList.add('hidden');
showAlert('Password updated successfully');
}
function executeAdminCommand() {
if (!currentUser || currentUser.id !== 0) return;
const command = adminCommand.value.trim();
if (!command) return;
adminCommand.value = '';
const parts = command.split(' ');
const cmd = parts[0].toLowerCase();
const args = parts.slice(1);
let response = '';
switch (cmd) {
case '/mute':
if (args.length !== 2) {
response = 'Usage: /mute id hours';
break;
}
const muteId = parseInt(args[0]);
const muteHours = parseInt(args[1]);
if (isNaN(muteId) || isNaN(muteHours) || muteHours <= 0) {
response = 'Invalid arguments';
break;
}
if (muteId === 0) {
response = 'Cannot mute admin';
break;
}
const muteUser = data.users.find(u => u.id === muteId);
if (!muteUser) {
response = 'User not found';
break;
}
const muteTime = new Date();
muteTime.setHours(muteTime.getHours() + muteHours);
data.mutedUsers[muteId] = muteTime.toISOString();
saveData();
response = `User ${muteUser.username} (ID: ${muteId}) muted for ${muteHours} hours`;
break;
case '/unmute':
if (args.length !== 1) {
response = 'Usage: /unmute id';
break;
}
const unmuteId = parseInt(args[0]);
if (isNaN(unmuteId)) {
response = 'Invalid ID';
break;
}
if (!data.mutedUsers[unmuteId]) {
response = 'User is not muted';
break;
}
delete data.mutedUsers[unmuteId];
saveData();
response = `User ID ${unmuteId} unmuted`;
break;
case '/del_m':
if (args.length !== 1) {
response = 'Usage: /del_m mid';
break;
}
const messageId = parseInt(args[0]);
if (isNaN(messageId)) {
response = 'Invalid message ID';
break;
}
const messageIndex = data.messages.findIndex(m => m.id === messageId);
if (messageIndex === -1) {
response = 'Message not found';
break;
}
data.messages.splice(messageIndex, 1);
saveData();
loadMessages();
response = `Message m${messageId} deleted`;
break;
case '/del_um':
if (args.length !== 1) {
response = 'Usage: /del_um id';
break;
}
const userId = parseInt(args[0]);
if (isNaN(userId)) {
response = 'Invalid user ID';
break;
}
const userMessages = data.messages.filter(m => m.userId === userId);
if (userMessages.length === 0) {
response = 'No messages found for this user';
break;
}
data.messages = data.messages.filter(m => m.userId !== userId);
saveData();
loadMessages();
response = `Deleted ${userMessages.length} messages from user ID ${userId}`;
break;
case '/limit_m':
if (args.length !== 1) {
response = 'Usage: /limit_m x';
break;
}
const newLimit = parseInt(args[0]);
if (isNaN(newLimit) || newLimit <= 0) {
response = 'Invalid limit';
break;
}
data.messageLimit = newLimit;
saveData();
updateMessageCounter();
response = `Message limit set to ${newLimit} per hour`;
break;
case '/limit_reset':
for (const userId in data.messageCounters) {
data.messageCounters[userId] = {
count: 0,
lastReset: new Date().toISOString()
};
}
saveData();
updateMessageCounter();
response = 'All message counters reset';
break;
case '/vipe_chat':
data.messages = [];
saveData();
loadMessages();
response = 'Chat cleared';
break;
case '/vipe_all':
data.messages = [];
data.users = data.users.filter(u => u.id === 0);
data.mutedUsers = {};
data.mutedIPs = {};
data.messageCounters = {};
data.deviceRegistrations = {};
data.messageLimit = 10;
data.nextMessageId = 1;
saveData();
loadMessages();
response = 'All data cleared except admin account';
break;
case '/change_n':
if (args.length < 2) {
response = 'Usage: /change_n id new_username';
break;
}
const changeId = parseInt(args[0]);
const newName = args.slice(1).join(' ');
if (isNaN(changeId)) {
response = 'Invalid ID';
break;
}
if (newName.length > 20) {
response = 'Username must be 20 characters or less';
break;
}
const changeUser = data.users.find(u => u.id === changeId);
if (!changeUser) {
response = 'User not found';
break;
}
changeUser.username = newName;
// Update all messages with new username
data.messages.forEach(message => {
if (message.userId === changeId) {
message.username = newName;
}
});
saveData();
loadMessages();
if (currentUser.id === changeId) {
usernameDisplay.textContent = newName;
userNameDisplay.textContent = newName;
}
response = `Username for ID ${changeId} changed to "${newName}"`;
break;
case '/change_p':
if (args.length !== 2) {
response = 'Usage: /change_p id new_password';
break;
}
const passId = parseInt(args[0]);
const newPass = args[1];
if (isNaN(passId)) {
response = 'Invalid ID';
break;
}
if (newPass.length > 20) {
response = 'Password must be 20 characters or less';
break;
}
const passUser = data.users.find(u => u.id === passId);
if (!passUser) {
response = 'User not found';
break;
}
passUser.password = newPass;
saveData();
response = `Password for ID ${passId} changed`;
break;
case '/check_ip':
if (args.length !== 1) {
response = 'Usage: /check_ip mid';
break;
}
const checkId = parseInt(args[0]);
if (isNaN(checkId)) {
response = 'Invalid message ID';
break;
}
const checkMessage = data.messages.find(m => m.id === checkId);
if (!checkMessage) {
response = 'Message not found';
break;
}
response = `Message m${checkId} was sent from IP: ${checkMessage.ip}`;
break;
case '/mute_ip':
if (args.length !== 2) {
response = 'Usage: /mute_ip ip hours';
break;
}
const muteIp = args[0];
const muteIpHours = parseInt(args[1]);
if (isNaN(muteIpHours) || muteIpHours <= 0) {
response = 'Invalid hours';
break;
}
const muteIpTime = new Date();
muteIpTime.setHours(muteIpTime.getHours() + muteIpHours);
data.mutedIPs[muteIp] = muteIpTime.toISOString();
saveData();
response = `IP ${muteIp} muted for ${muteIpHours} hours`;
break;
case '/unmute_ip':
if (args.length !== 1) {
response = 'Usage: /unmute_ip ip';
break;
}
const unmuteIp = args[0];
if (!data.mutedIPs[unmuteIp]) {
response = 'IP is not muted';
break;
}
delete data.mutedIPs[unmuteIp];
saveData();
response = `IP ${unmuteIp} unmuted`;
break;
case '/list':
const mutedUsersList = Object.entries(data.mutedUsers)
.map(([id, time]) => {
const user = data.users.find(u => u.id === parseInt(id));
const username = user ? user.username : 'Unknown';
return `User: ${username} (ID: ${id}) until ${new Date(time).toLocaleString()}`;
})
.join('\n');
const mutedIPsList = Object.entries(data.mutedIPs)
.map(([ip, time]) => `IP: ${ip} until ${new Date(time).toLocaleString()}`)
.join('\n');
response = 'Muted Users:\n' + (mutedUsersList || 'None') + '\n\nMuted IPs:\n' + (mutedIPsList || 'None');
break;
case '/help':
helpModal.classList.remove('hidden');
break;
default:
response = 'Unknown command. Type /help for available commands';
}
if (response) {
showAlert(response);
}
}
function showAlert(message) {
const alertDiv = document.createElement('div');
alertDiv.className = 'fixed bottom-4 right-4 bg-gray-800 text-white px-4 py-3 rounded shadow-lg message-animation';
alertDiv.textContent = message;
document.body.appendChild(alertDiv);
setTimeout(() => {
alertDiv.classList.add('opacity-0', 'transition-opacity', 'duration-300');
setTimeout(() => {
document.body.removeChild(alertDiv);
}, 300);
}, 3000);
}
// Initialize
updateStats();
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Dapshen/null-v-0" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |