├── LICENSE ├── README.md └── index.php /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 danmed 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PHPIndex 2 | 3 | **Version:** 1.6 4 | **License:** MIT 5 | 6 | PHPIndex is a single-file, zero-dependency script that provides a clean and modern interface for browsing a directory on your web server. It's designed for developers who need a quick and easy way to access files, generate download/execution commands, and perform basic file management. 7 | 8 | 9 | 10 | ## Features 11 | 12 | - **Single-File Deployment:** Just drop `PHPIndex.php` into any directory. 13 | - **Sub-folder Navigation:** Browse through subdirectories with clickable breadcrumb navigation. 14 | - **Command Generation:** Instantly generate download or execution commands for `Wget`, `Curl`, and `PowerShell`. 15 | - **Live File Filtering:** Filter the file list in real-time with wildcard support (`*.sh`, `script*`, etc.). 16 | - **File Content Preview:** View the contents of any file with syntax highlighting. 17 | - **Dark Mode:** Includes a sleek dark mode with automatic theme detection and a manual toggle. 18 | - **Secure File Management (Login Protected):** 19 | - Create new files. 20 | - Edit existing files. 21 | - Delete files. 22 | - **Secure by Default:** Features built-in protection against directory traversal, XSS, and CSRF attacks. 23 | 24 | --- 25 | 26 | ## Setup 27 | 28 | 1. **Download:** Get the `PHPIndex.php` file. 29 | 2. **Upload:** Place the file in the directory you want to browse on your web server. 30 | 3. **(Recommended) Set Your Password:** 31 | - Open `PHPIndex.php` in a text editor. 32 | - **To set/reset the password:** Find the line that starts with `$passwordHash = ` and change it to look exactly like this: `$passwordHash = '';` (the hash must be empty). 33 | - Next, find the line `$plainTextPassword = 'your_password_here';` and change `'your_password_here'` to your new secure password. 34 | - Save and upload the file. The script will automatically generate a new secure hash from your plain text password the first time you log in. 35 | 36 | That's it! You can now access the directory through your browser. 37 | 38 | --- 39 | 40 | ## Troubleshooting & Usage 41 | 42 | ### How do I edit or delete existing files? 43 | 44 | The edit and delete functions require you to be logged in. If you have not set a password, these features will not be available. 45 | 46 | If you are logged in but still can't edit or delete a file that you uploaded via FTP/SSH, it is almost certainly a **file permissions** issue. 47 | 48 | The web server runs as a specific user (e.g., `www-data` or `apache`), and that user needs permission to modify files owned by your FTP/SSH user. 49 | 50 | #### Quick Fix (Recommended) 51 | 52 | The easiest solution is to change the "owner" of the project files to the web server user. 53 | 54 | 1. **Find your web server's user:** This is commonly `www-data` on Debian/Ubuntu systems or `apache` on CentOS/RHEL systems. 55 | 2. **Connect to your server via SSH.** 56 | 3. **Run the `chown` (change owner) command:** 57 | - Navigate to the parent directory of where you placed `PHPIndex.php`. 58 | - Run the following command, replacing `www-data:www-data` if your server user is different and `/path/to/your/project` with the correct directory path. 59 | 60 | ```bash 61 | sudo chown -R www-data:www-data /path/to/your/project 62 | ``` 63 | The `-R` flag makes the change recursive, applying it to all files and folders inside. 64 | 65 | #### Alternative Fix (If you can't change ownership) 66 | 67 | If you must keep the files owned by your personal user, you can grant "group" write permissions instead. 68 | 69 | 1. **Find the web server's group name** (usually the same as the user, e.g., `www-data`). 70 | 2. **Add your user to the web server's group:** 71 | 72 | ```bash 73 | sudo usermod -a -G www-data your_username 74 | ``` 75 | You will need to log out and log back in for this change to take effect. 76 | 3. **Grant write permissions to the group** for your project directory: 77 | ```bash 78 | sudo chmod -R g+w /path/to/your/project 79 | ``` 80 | 81 | After applying either of these fixes, the edit and delete functions in PHPIndex should work as expected. 82 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 160 | 161 | 162 | 163 | 164 | 165 | PHPIndex - File Lister 166 | 167 | 168 | 169 | 170 | 171 | 176 | 185 | 186 | 187 | 188 |
189 |
190 |
191 |

PHPIndex

192 |
193 | 194 | 195 | Logout 196 | 197 | 198 | 199 | 200 | 204 |
205 |
206 | 207 | 208 |
209 | 210 |
211 | 212 | 213 |

This page lists files in the current directory. You can view content, get download/execute commands for Wget, Curl, or PowerShell, or filter the list using wildcards (e.g., `*.sh`).

214 | 215 |
216 |
217 | 218 | 219 |
220 | 221 |
222 | 223 |
224 | 225 |
226 | 227 | '; 230 | echo '
    '; 231 | echo '
  1. '; 232 | echo 'PHPIndex'; 233 | echo '
  2. '; 234 | $pathParts = ($relativePath !== '.' && $relativePath !== '') ? explode('/', $relativePath) : []; 235 | $currentPath = ''; 236 | foreach ($pathParts as $part) { 237 | $currentPath .= $part . '/'; 238 | echo '
  3. /'; 239 | echo '' . htmlspecialchars($part) . ''; 240 | echo '
  4. '; 241 | } 242 | echo '
'; 243 | ?> 244 | 245 |
246 | 282 | 283 |
284 | 285 | 286 |
287 |
288 | 'bash', 'js' => 'javascript', 'py' => 'python', 'md' => 'markdown']; 307 | $languageClass = isset($langMap[$fileExtension]) ? $langMap[$fileExtension] : $fileExtension; 308 | ?> 309 |
310 |
311 |
312 | 313 | 314 |
315 |
316 |
317 | 322 | 326 |
327 |
331 |
332 | 333 |
334 |
335 |
336 |
337 |
338 | View Content 339 |
340 |
341 |
342 |
343 | 344 |
345 | 346 | 347 |
348 | 349 |
350 |
351 |

No items found that match your filter.

'; 355 | 356 | if (count($directories) === 0 && count($files) === 0) { 357 | echo '

This directory is empty.

'; 358 | } 359 | ?> 360 |
361 | 362 | 371 | 372 |
373 | 374 | 375 | 376 | 377 | 393 | 394 | 395 | 416 | 417 | 435 | 436 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 588 | 589 | 590 | 591 | --------------------------------------------------------------------------------