PHP Page Access Control - php

I use simple access control to allow or restrict users to pages with in a site running on our LAN.
Each page has an unique UID, and the user can only access that page if the UID is in their access control list. This works well.
Users can access the required pages, pages they are not allowed access to are hidden and if they try to go to a 'hidden' page by entering the url then they are redirect back to the home page.
Currently when they log in or if logged in click on the hyper link ('/local/users') they are taken to the default page within /local/users/
The default page is defined in the the .htaccess file and is called home.php Again this is all working well.
What I'd like to do now is allow users access to a new simple home page. Within their ACL I can add a new value ('base'). If this value is set then I can redirect to the user from home.php to base.php
The issue I have is once this value is set, users can only go to base.php as home.php would detect the base value and redirect them to base.php
I'm trying to work out if it's possible when base is set that home.php redirects to base.php BUT have some way they they can also access home.php
I'm thinking..
If they login or goto a href='/users/local' and base is set then home.php will redirect to base.php
if they click on a link a href='/users/local/home.php' and base is set they are allowed access to home.php
if they are in home.php and base is set, if they refresh they stay within home.php
Is any of this possible ?
Thanks

The simplest way I can think of:
/users/local/ Landing page is set to index.php
index.php checks if it can send the user to /users/local/base.php if not, send the user to /users/local/home.php instead.
Since home.php does not do any redirect, this can be accessed by anyone who types the URL, or follow a direct link to it.

Related

How to show only domain name or custom url in the address bar?

Once logged in, the webpage should go to user page but url should show only custom url.
For example:
If I have a form in www.example.com/startups/registration/fill_form once I logged in, it displays as www.example.com/startups/registration/username.
Expected output:
Once logged in successfully, it should redirect to www.example.com/startups/registration/username page but url should be be displayed like www.example.com/username.
As facebook, though we logged in, it will display url as www.facebook.com
I had gone through routing technique. Routing does like from the existing url, we can redirect to expected page. Now I want a reverse technique, when redirecting to expected page, url should be displayed as custom url.
I need like URL masking or display custom url using frameset or iframe as such.
check this website. Whatever option we click, it will redirect to the desired page but url in the address bar remains the same. I want exactly like that.
If logged in, address bar should show only domain name
$route['default_controller'] = '****'; // mantion the desired controller after login IN
And mantion the redirect(); function in end of login success functionality.
Then If you logged then automatically redirect to your domain name only. but call the your default controller in background process.
Well... you need to use .htaccess to handle this issue. Just take a look following tutorial for your better understanding...
http://code.tutsplus.com/tutorials/using-htaccess-files-for-pretty-urls--net-6049
http://culttt.com/2011/11/16/how-to-make-vanity-urls-using-php-htaccess-and-mysql/
http://www.9lessons.info/2013/11/htaccess-file-tutorial-and-tips.html
You say http://www.yourdomain.com/ site
That site screens from https://www.1and1.com/?kwk=77902898 using iframes.
So only If you click login button, then only redirect inside of iframe.
Without change URL.
If you need same format, then apply one domain in another domain using iframe

How to get the link that the user tried to visit, from a 404 custom page made in php

I have a website in different languages, thus I want to show a custom 404 page for each language.
Is there a way to find out which page the user tried to visit (that didn't exist) in order to find out which language I should display the 404 page?
The web server is Apache.
Thank you very much.
if you use .htaccess file for redirect then add
ErrorDocument 404 /yourdir/error/404page.php
then use request uri in session which stores the page user are visiting i.e.
$_SESSION['req_uri'] = $_SERVER['REQUEST_URI'];
then redirect user to $_SESSION['req_uri'].
where $_SESSION['req_uri'] is the page user trying to access.

WordPress static index page

I am editing a WordPress website, and I'd like to put a static page on index like "We're under construction". But when I edit the index.php file to show this page, I can't acess wp-login.php anymore, because it redirects me to index.php again.
I made a plugin just for that: WP Show Site by IP.
The advantage of using IP over login to filter your access is that sometimes you want to see your websites as an anonymous user rather than a logged in one (which could have different features/capabilities).

How to make Wordpress login page my home page?

I'm currently using a plugin called Members Only to restrict certain users from accessing my site by redirecting them to the wp-login.php page.
My site's login url currently looks like this:
http://localhost/home-page/login/
Every time someone accesses a page before logging in the URL changes to this:
http://localhost/home-page/login/?redirect_to=/home-page/
Is there anyway to remove the /login/ section of the URL and have the login page's URL be:
http://localhost/home-page/?
A quick way to accomplish this would be to make a .htaccess rewrite rule to make h*ttp://localhost/home-page/ actually reference http://localhost/home-page/login/ and then in the admin panel of wordpress set up a custom homepage that actually represents what you want displayed after login.

Let PHP file read cookies when it it imported through readfile() function?

I'm loading my files using read file so it seems like there are like 5 pages on the index page, and arguments index the url specify what will show.
So for example, my profile site http://profile.campatet.com has 3 pages:
login page
profile page
search page.
If the url is http://profile.campatet.com/?s=something, it will load search.php into the index page and you will see a search page.
If it's http://profile.campatet.com/?user=something, it will load profile.php into the index page and it will be a user profile.
If it's just http://profile.campatet.com/, it will load login.php into the index page and it will be the login page.
Now, the my profile page is loaded into the index page when the index page uses the readfile() function. However, the my profile page needs to check a cookie to make sure the person who is accessing the my profile page actually is the account owner.
However, the page can't find the cookie when it is loaded through the readfile function for some reason. It works properly when I open it as a independent file, so I know there is nothing wrong with my code for the self profile page.
Why is this happening?
Use include or its variants require, require_once etc. instead of readfile()

Categories