Forgot Password
 Register
View: 16|Reply: 1

How to reset Admin password with Toolbox Discuz! X5.0

[Copy Link]
Posted on yesterday 23:35 | Show all floors |Read Mode
  There's a small tip for webmaster to use Toolbox.
+ By default, install/index.php will redirect us to Installation Wizard.
+ If we rename index.php to tool.php and we'll browse: https://yourdicuz-forum.com/install/tool.php

  That's the way we reach Discuz! Toolbox for :
- reset founder password: the fastest way to reset admin root password
- update cache: when you need apply changes to the website
- Restore database: to rollback website to most stable database backup version.
- directory detection: check which files, folders are not matched with origional one.


Demo: Discuz! X 5.0 English Package Installation Wizard



Reply

Use Props Report

 Thread Author| Posted on 9 hour(s) ago | Show all floors
For security reason, we'll add a very simple authentication process to access install/index.php or install/tool.php

  1. // After line: define('IN_DISCUZ', true);

  2. // Tool mode authentication
  3. define('TOOL_MODE_PASSWORD', 'your_strong_password_here'); // Change this!

  4. $request_uri = $_SERVER['REQUEST_URI'];
  5. if (basename($request_uri) != 'index.php') {
  6.     // This is tool mode, require authentication
  7.     session_start();
  8.    
  9.     // Check if already authenticated
  10.     if (!isset($_SESSION['tool_auth']) || $_SESSION['tool_auth'] !== true) {
  11.         // Handle login form submission
  12.         if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['tool_password'])) {
  13.             if ($_POST['tool_password'] === TOOL_MODE_PASSWORD) {
  14.                 $_SESSION['tool_auth'] = true;
  15.                 // Redirect to remove POST data
  16.                 header('Location: ' . $_SERVER['REQUEST_URI']);
  17.                 exit;
  18.             } else {
  19.                 $error = 'Invalid password!';
  20.             }
  21.         }
  22.         
  23.         // Show login form
  24.         header('HTTP/1.0 403 Forbidden');
  25.         echo '<!DOCTYPE html>
  26.         <html>
  27.         <head>
  28.             <title>Tool Mode Authentication</title>
  29.             <meta charset="utf-8">
  30.             <style>
  31.                 body { font-family: Arial, sans-serif; background: #f0f0f0; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; }
  32.                 .login-box { background: white; padding: 30px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); width: 300px; }
  33.                 h2 { margin-top: 0; color: #333; }
  34.                 input { width: 100%; padding: 10px; margin: 10px 0; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box; }
  35.                 button { width: 100%; padding: 10px; background: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; }
  36.                 button:hover { background: #0056b3; }
  37.                 .error { color: red; margin-bottom: 10px; font-size: 14px; }
  38.             </style>
  39.         </head>
  40.         <body>
  41.             <div class="login-box">
  42.                 <h2>Tool Mode Access</h2>
  43.                 ' . (isset($error) ? '<div class="error">' . htmlspecialchars($error) . '</div>' : '') . '
  44.                 <form method="post">
  45.                     <input type="password" name="tool_password" placeholder="Enter tool password" autofocus>
  46.                     <button type="submit">Authenticate</button>
  47.                 </form>
  48.             </div>
  49.         </body>
  50.         </html>';
  51.         exit;
  52.     }
  53. }
Copy Code


That'll protect your tool from black hat hackers
Reply

Use Props Report

You need to log in before you can reply Login | Register

Forum Credit Rules

Close

Editors SelectedPrevious /2 Next

Archiver|Mobile|Darkroom|Privacy|DSC

GMT+7, 2026-05-08 18:29 , Processed in 0.080974 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

Quick Reply Back to Top Return to List