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

remove hard-coded /admin/ path #2461

Merged
merged 1 commit into from
Jan 22, 2023

Conversation

gstrauss
Copy link
Contributor

What does this PR aim to accomplish?:

remove hard-coded /admin/ path; relocatable

This does not change or require any changes to where pi-hole installs AdminLTE, which at the moment is /var/www/html/admin/, and accessed via http://pi.hole/admin/, but this change allows an administrator to manually place the files elsewhere, and to allow the same functionality when accessed from an alternative url-path, e.g. http://localhost/pihole/admin/, a url-path less likely to conflict with an already existing website.

This PR uses a suffix match for /login.php rather than exact match /admin/login.php


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributors guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented my proposed changes within the code and I have tested my changes.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the EUPL 1.2 license
  5. I have squashed any insignificant commits. (git rebase)
  6. I have checked that another pull request for this purpose does not exist.
  7. I have considered, and confirmed that this submission will be valuable to others.
  8. I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  9. I give this submission freely, and claim no ownership to its content.

  • I have read the above and my PR is ready for review. Check this box to confirm

@gstrauss
Copy link
Contributor Author

@rdwebdesign I think this PR is up your alley.

Is this error perhaps due to recent changes elsewhere which broke CI for the pi-hole repo?

Run sudo update-alternatives --set php /usr/bin/php8.0
update-alternatives: error: alternative /usr/bin/php8.0 for php not registered; not setting
Error: Process completed with exit code 2.

@gstrauss
Copy link
Contributor Author

Where can I see the errors during linting from my changes to password.php?

Files that were not fixed due to errors reported during linting before fixing:
   1) /github/workspace/scripts/pi-hole/php/password.php

@gstrauss gstrauss force-pushed the relative-links-relocatable branch 3 times, most recently from 138c6e2 to d2678b6 Compare December 19, 2022 04:30
@rdwebdesign
Copy link
Member

Is this error perhaps due to recent changes elsewhere which broke CI for the pi-hole repo?

This error was already fixed on development branch (devel).

You need to base your code (and target your PR) on devel branch.

@gstrauss gstrauss changed the base branch from master to devel December 19, 2022 05:12
@gstrauss
Copy link
Contributor Author

Is this error perhaps due to recent changes elsewhere which broke CI for the pi-hole repo?

This error was already fixed on development branch (devel).

You need to base your code (and target your PR) on devel branch.

Okay. Updated PR and rebased on devel.

(The devel branch here is named differently from development in the other repos. Close, but not the same name!)

scripts/pi-hole/php/password.php Outdated Show resolved Hide resolved
@gstrauss gstrauss force-pushed the relative-links-relocatable branch 2 times, most recently from 803e119 to a73d9be Compare December 19, 2022 18:19
@gstrauss
Copy link
Contributor Author

It would appear that stickler-ci part of the tests is hung or extremely backlogged.
That test has been queued for almost 30 mins.

@rdwebdesign
Copy link
Member

Reload the page.
It's probably a problem with the web interface.

The tests were finished:
image

@gstrauss
Copy link
Contributor Author

Once it started, it took 3 seconds. Before it started, it sat almost 30 mins in the queue

Anyway, I made the change you requested.

Signed-off-by: Glenn Strauss <gstrauss@gluelogic.com>
Copy link
Member

@PromoFaux PromoFaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. It surprises me that it's taken until php 8 to have handy functions such as str_ends_with, or even str_contains

I suppose after seeing this SO answer we could do something like:

if ($_SERVER['REQUEST_METHOD'] === 'POST' && strpos($_SERVER['SCRIPT_NAME'], '/login.php) == false) {
     header('Location: '.$redirect_url);
     exit;
}

But really that's just nitpicking on my part. Happy with code as is

@PromoFaux PromoFaux changed the title remove hard-coded /admin/ path; relocatable remove hard-coded /admin/ path Jan 22, 2023
@PromoFaux PromoFaux merged commit 1f194ef into pi-hole:devel Jan 22, 2023
@pralor-bot
Copy link

This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/pi-hole-web-v5-18-2-and-core-v5-15-1-released/60695/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants