Jump to content
MakeWebGames

rockwood

Members
  • Posts

    433
  • Joined

  • Last visited

  • Days Won

    15

Everything posted by rockwood

  1. Good Move
  2. <?php declare(strict_types=1); /** * --------------------------------------------------------- * Simple PHP MVC Example (Single File) * --------------------------------------------------------- * This file demonstrates a basic MVC structure using: * * Model → Handles database logic * Controller → Handles request logic * View → Handles presentation * * Documentation follows PHPDoc conventions aligned with * PSR coding standards (PSR-12 style). * * Requirements: * - PHP 8+ * - MySQL database with table `users` * * Example URL: * http://localhost/index.php?id=1 * --------------------------------------------------------- */ /** * --------------------------------------------------------- * MODEL * --------------------------------------------------------- */ /** * Class UserModel * * Responsible for interacting with the database * for user related operations. */ class UserModel { /** * PDO database connection instance. * * @var PDO */ private PDO $pdo; /** * Constructor. * * @param PDO $pdo Database connection instance */ public function __construct(PDO $pdo) { $this->pdo = $pdo; } /** * Retrieve user by ID. * * @param int $id User ID * * @return array|null Returns user data or blank array */ public function getUserById(int $id): ?array { $stmt = $this->pdo->prepare( "SELECT * FROM users WHERE id = :id" ); $stmt->execute([ 'id' => $id ]); $user = $stmt->fetch(PDO::FETCH_ASSOC); return $user ?: []; } } /** * --------------------------------------------------------- * CONTROLLER * --------------------------------------------------------- */ /** * Class UserController * * Handles user related requests and communicates * between the model and the view. */ class UserController { /** * User model instance. * * @var UserModel */ private UserModel $userModel; /** * Constructor. * * @param UserModel $userModel User model dependency */ public function __construct(UserModel $userModel) { $this->userModel = $userModel; } /** * Show user profile. * * @param int $id User ID * * @return void */ public function showUser(int $id): void { $user = $this->userModel->getUserById($id); view_user($user); } } /** * --------------------------------------------------------- * VIEW * --------------------------------------------------------- */ /** * Render user view. * * @param array|null $user User data * * @return void */ function view_user(?array $user): void { ?> <!DOCTYPE html> <html> <head> <title>User Profile</title> <meta charset="UTF-8"> </head> <body> <?php if ($user): ?> <h1><?= htmlspecialchars($user['name']) ?></h1> <p> Email: <?= htmlspecialchars($user['email']) ?> </p> <?php else: ?> <p>User not found.</p> <?php endif; ?> </body> </html> <?php } /** * --------------------------------------------------------- * APPLICATION ENTRY POINT * --------------------------------------------------------- */ /** * Create database connection. */ $pdo = new PDO( "mysql:host=localhost;dbname=test;charset=utf8mb4", "root", "", [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ] ); /** * Initialize MVC components. */ $userModel = new UserModel($pdo); $userController = new UserController($userModel); /** * Get user ID from request. */ $userId = isset($_GET['id']) ? (int) $_GET['id'] : 0; /** * Handle request. */ $userController->showUser($userId); I love this way
  3. Network error. Please check your connection and try again. on desktop
  4. Hello everyone! I wanted to share a project I've been working on recently. Like many people here, I grew up playing classic browser mafia games and always loved the core gameplay loops (Crimes, Casino, PvP, etc). Instead of using the traditional MCCodes architecture, I decided to build the project with a modern full-stack setup while keeping the classic gameplay feeling. So far the project is built with the following stack: • Node.js • Prisma ORM • Express.js • PostgreSQL • React (Fetch API) • Tailwind CSS The goal is to create a modern browser-based mafia game with smoother UI interactions and a more scalable backend. Some of the things I’m focusing on: Modern backend architecture using Node.js + Prisma Clean API structure with Express React-based frontend for dynamic UI Tailwind CSS for a responsive modern interface PostgreSQL database for reliability and scalability I'm still actively working on new features and improving the overall gameplay experience. Below is a preview of the current example profile UI. Would love to hear feedback from other developers here!
  5. Modern backend built with PHP 8+, using PDO prepared statements throughout. The codebase uses strictly typed functions and robust CSRF token verification for improved security. Could you show an example of how this is implemented? Overall, you’ve done a great job—this looks like excellent work. For my stack, I’m using Node.js + Prisma + Express + PostgreSQL + React (with the Fetch API) + Tailwind CSS.
  6. Cronus is still active in Torn, and I think ColdBlooded was his team member years ago. Is it true that you both created Criminal Impulse? That game was very impressive.
  7. are you using shared hosting? that is painful stuff XD
  8. i am there already
  9. JavaScript helps make frontend development simpler, more efficient, and visually appealing.
  10. awesome work
  11. I’m genuinely impressed he’s still active here. Much respect—cheers, bro, and Happy New Year!
  12. $data = []; $placed = []; foreach ($locations as $location) { // Hook $location = (new Hook("alterModuleData"))->run([ "module" => "travel", "user" => $this->user, "data" => $location ], 1)["data"]; // Map $map = (!empty($location['L_map']) && file_exists($location['L_map'])) ? $location['L_map'] : "themes/" . _setting('theme') . "/assets/img/pages/travel/map.png"; [$width, $height] = getimagesize($map); // Leader name $leader = "None"; if ($location['L_leader']) { $leader = (new Gang($location['L_leader']))->getGang()['name']; } // Random position (no overlap) $pos = $this->randomPosition($width, $height, $placed); $placed[] = $pos; // Result $data[] = [ "location" => $location["L_name"], "color" => $location["L_color"], "x" => $pos['x'], "y" => $pos['y'], "cost" => $location["L_cost"], "id" => $location["L_id"], "leader" => $leader, "cooldown" => $this->timeLeft($location["L_cooldown"]) ]; }
  13. merry Christmas
  14. Everyone’s still around 🙂🎮 Real life has us busy, and things have changed, but the passion for games and coding unique ideas is still here 💻🔥🕹️
  15. can i see yours game?
  16. i am the big hater of : global $db, $set;
  17. PHP is still going strong, and Laravel, combined with Breeze, takes it to a whole new level of simplicity and power.
  18. what kind of project you are doing?
  19. Glad to see MySQLi is still in use!
  20. I'm glad to see this community remains active and that most members are ready to support one another.
  21. I used to code for the community, but life got pretty busy. Now I’m ready to dive back in—and if anyone’s interested in joining, I’d be really happy to collaborate. I’m restarting the project and plan to be super active with it!
  22. looks impressive
×
×
  • Create New...