The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
switching index.php
#1
ok so I wanted to change the index.php file in the root to the index.php in the user folder as it is a redirect page that takes to one page if logged in and to the log in page if they are not this what I want my site to do now when I switched in my site it took and gave me a error 500 I know this is ussually a .htaccess issue but wanted know where do I need the .htaccess file so it will work
  Reply
#2
So if you're getting an error 500, it could also be that your server has error reporting turned off. Just go to both of those pages and just after the opening
Code:
<?php
add these two lines...

Code:
error_reporting(E_ALL);
Code:
ini_set('display_errors', 1);

See if that gives you a better explanation.

As far as what you're actually trying to accomplish, I'm not 100{3bc1fe685386cc4c3ab89a3f76566d8931e181ad17f08aed9ad73b30bf28114d} sure if I understand you.
I'm thinking you want your

users/index.php to be your actual index.php which is fine. Just get rid of all the code in there that redirects you to the home page. If nothing else, just start with

Code:
<?php
Code:
error_reporting(E_ALL);
Code:
ini_set('display_errors', 1);
Code:
echo "This is home.";

Then on whichever page you want to react based on whether the user is logged in or not, use that same logic

Code:
if(isset($user) && $user->isLoggedIn()){
Code:
Redirect::to($us_url_root.'users/account.php');
Code:
}else{
Code:
Redirect::to($us_url_root.'users/login.php');
Code:
}
  Reply
#3
It was actually a debugging error on myside I didn't have the pages pointing to the right places
  Reply
#4
Hi! I have a question regarding this topic.

I built an index.php with an if/else statement. If the user is not logged in it will display the title and a link to the users/login.php. Else the logged in user will see the content on the index.php.

I want the users to be redirected to the index.php after the login. Therefore I changed the users/index.php to

<pre>
Code:
<?php
require_once 'init.php';
if(isset($user) && $user->isLoggedIn()){
  Redirect::to($us_url_root.'index.php');
}else{
  Redirect::to($us_url_root.'users/login.php');
}
die();
?>
</pre>







Unfortunately users with access to the users/account.php (I did some translation to german, removed the gravatar but changed nothing else) don't get redirected to the index.php after logging in. The standard user has access to a different account_s.php. I copied the code from the account.php, hid the email inputs and set the fname/lname input to readonly (the useraccounts for the standard users are created manually without any email and should only be able to change the password). These users get redirected correctly to the root index.php. But I think what happens is that the standard users is also redirected to the account.php. Since he doesn't have access to it but is logged in, he gets redirected to the root index.php.

The users/index.php has public access. If I'm logged and type in the "localhost/.../users/index.php" I get redirected correctly to the root index.php.

Do I have to change any code in the login.php? I'm constantly learning but I'm not good enough to understand every process/line in the login.php

Edit: I activated the web-development tools of my Firefox and saw that my guess was correct (the standard user is redirected to the account.php and then to the index.php (because he doesn't have access to it)). The users/index.php isn't called while login in at all.
  Reply
#5
I'm not 100{3bc1fe685386cc4c3ab89a3f76566d8931e181ad17f08aed9ad73b30bf28114d} sure that I'm understanding, but I think I get the gist.

There is a file usersc/custom_login_script.php which decides what happens just after someone logs in. I don't know your access levels but let's assume that you have 1 for user, 2 for admin, 3 for your "other" group. The thing you want to think about is that everyone probably has user access 1 so you want to do that last.

You can do something like

Code:
if(hasPerm([2],$user->data()->id)){
Code:
Redirect::to($us_url_root.'users/admin.php');
Code:
}elseif(hasPerm([3],$user->data()->id)){
Code:
Redirect::to($us_url_root.'users/someotherpage.php');
Code:
}else{
Code:
Redirect::to($us_url_root.'users/account.php');
Code:
}

Note that hasPerm takes an array so you can do [3,4,5,6,7]
  Reply
#6
Thanky you so much, that did it! I always thought that after the login the /users/index.php file is called. I completely misunderstood the purpose of the custom_login_script and never had a look in it. Thanks! It constantly surprises me how well thought through Userspice is Smile
  Reply
#7
Awesome! Glad it helped. When I first wrote userspice, everyone kept editing my code which meant that I broke their site on updates. So, basically I figured out all the places that people were editing and made a way so they didn't have to.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)