Hi Everyone
i need to start specific ADMIN scripts (where i include also the application_top.php) and i found out, that the cli redirects mit alway to login (as i do not have a admin session in the php commandline)
what would be the nicest way to workarround the session check? (of course i could not include the application_top or i could make a if($_GET['php']=="cli" thann don't redirect, but i don't like to change core and i don't like to make security risks)
thank you for any helps,..
PHP CLI - rediret to login
Re: PHP CLI - rediret to login
If you don't need all of application_top just use this:
require('../../includes/configure.php');
require('../../includes/functions/database.php');
echo "<br />active server : " . DB_SERVER . "<br/>active database : " . DB_DATABASE;
tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE) or die('Unable to connect to database server!');
require('../../includes/configure.php');
require('../../includes/functions/database.php');
echo "<br />active server : " . DB_SERVER . "<br/>active database : " . DB_DATABASE;
tep_db_connect($server = DB_SERVER, $username = DB_SERVER_USERNAME, $password = DB_SERVER_PASSWORD, $database = DB_DATABASE) or die('Unable to connect to database server!');
-
- Lead Developer
- Posts: 2656
- Joined: Tue Nov 05, 2019 6:02 pm
- Has thanked: 4 times
- Been thanked: 182 times
Re: PHP CLI - redirect to login
Set up the .htpasswd file authentication. Then call the script https://username:password@example.com/admin/page.php -- obviously replacing username, password, example.com, admin, and page.php with the actual values from your shop.
Alternately create three pages of the script: web.php, cli.php, and include.php. Put all the logic in include.php and include it from both the other scripts. Then use admin/web.php in the browser and use the outside_web_root/cli.php in your CLI script.
Alternately create three pages of the script: web.php, cli.php, and include.php. Put all the logic in include.php and include it from both the other scripts. Then use admin/web.php in the browser and use the outside_web_root/cli.php in your CLI script.