Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hostname hardcoded #19

Closed
martic opened this issue Jun 6, 2024 · 7 comments
Closed

Hostname hardcoded #19

martic opened this issue Jun 6, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@martic
Copy link

martic commented Jun 6, 2024

I use .test as my local domain.

Can you get the configured domain from the Preferences:

image

@LebToki
Copy link
Owner

LebToki commented Jun 6, 2024

Hi,

did it not automatically detect .test at your end ?

very strange
open index.php and replace all instances of .local to .test
and I'll check why it didn't detect it automatically !

Can I ask you a question :
Are your domains listing ?
if so then check Line 218 and 219 to see if your Laragon installation is installed in a different location and if you need a customized version then please let me know!

Thanks for reporting it

@martic
Copy link
Author

martic commented Jun 6, 2024

it did not, its hard coded in the code.
so I added a variable.

$ignored = array('favicon_io');
$folders = array_filter(glob('*'), 'is_dir');
$local_domain = ".test";

and replaced the '.local' with $local_domain
like this

htmlspecialchars($host) . $local_domain . '/user"

The domains where listing, just the links where all to .local

@LebToki
Copy link
Owner

LebToki commented Jun 6, 2024

$admin.link --> lines 951, 956, 961, 971, 976, 981 and 992 should be changed too to .test to have this all done for you smoothly
until i release another version by the weekend to test why it didn't automatically detect your .test

@martic
Copy link
Author

martic commented Jun 6, 2024

thanks. Also check the email page that's also go a D: drive hard link

@LebToki
Copy link
Owner

LebToki commented Jun 6, 2024

for open_email.php
inside /assets/inbox/

I can think for this for now:

<?php
    // Define potential paths
    $emailFilePaths = [
        'C:/laragon/bin/sendmail/output/',
        'D:/laragon/bin/sendmail/output/'
    ];

    function findEmailFile($filename, $paths) {
        foreach ($paths as $path) {
            $filePath = rtrim($path, '/') . '/' . basename($filename);
            if (file_exists($filePath)) {
                return $filePath;
            }
        }
        return false;
    }

    if (isset($_GET['email'])) {
        $emailFile = findEmailFile($_GET['email'], $emailFilePaths);
        if ($emailFile) {
            $content = file_get_contents($emailFile);
            if ($content === false) {
                echo "Error reading email file.";
            } else {
                // Decode and display content as HTML
                $decodedContent = htmlspecialchars_decode($content, ENT_QUOTES);
                echo nl2br($decodedContent);
            }
        } else {
            echo "Email not found.";
        }
    } else {
        echo "No email specified.";
    }
?>

LebToki added a commit that referenced this issue Jun 6, 2024
Date: 2024-06-05

Changes:

Dynamic Email File Path Detection in open_email.php:

Issue: Hardcoded file path to the D: drive for email files caused issues for users with different drive setups.
Fix: Introduced a function to dynamically check both C:/laragon/bin/sendmail/output/ and D:/laragon/bin/sendmail/output/ directories. The script now searches both paths and reads the email file from whichever path it finds the file.
Code Change:
Added function findEmailFile to check both potential paths.
Updated logic to call this function and fetch the email file dynamically.
Dynamic Host Template in index.php:

Issue: Hardcoded .local domain suffix caused issues for users with different local domain suffixes like .test.
Fix: Introduced a configuration option to set the domain suffix dynamically. This allows the dashboard to adapt to different environments without hardcoding the domain suffix.
Code Change:
Replaced hardcoded .local with a configurable variable $domainSuffix.
Updated all relevant parts of the code to use this variable for generating URLs.
Bug Fixes:

GitHub Issue #19: Fixed the hardcoded D: drive issue in open_email.php as reported by a user.
Domain Suffix Configuration: Resolved issues related to hardcoded .local domain suffix in the dashboard.
Contributors:

Tarek Tarabichi
Community feedback from GitHub @martic Issue #19
@LebToki
Copy link
Owner

LebToki commented Jun 6, 2024

Changes pushed for version 2.3.5 thanks for the report!

@LebToki LebToki added the bug Something isn't working label Jun 6, 2024
@LebToki
Copy link
Owner

LebToki commented Jun 6, 2024

Issue closed for now !
Thanks again @martic

@LebToki LebToki closed this as completed Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants