diff options
author | Arno Richter <mail@arnorichter.de> | 2022-01-26 22:54:31 +0100 |
---|---|---|
committer | Arno Richter <mail@arnorichter.de> | 2022-01-26 22:54:31 +0100 |
commit | 92c6aa46e73615d433bbef223f35921e5bf12e19 (patch) | |
tree | ecbc2d7ec79f67c539e6d3f78cf8019ae8b0425a | |
parent | 8ed87afb6aa52e6398ade891ca07fdcc4b15525c (diff) | |
download | microblog-92c6aa46e73615d433bbef223f35921e5bf12e19.tar.gz microblog-92c6aa46e73615d433bbef223f35921e5bf12e19.tar.bz2 microblog-92c6aa46e73615d433bbef223f35921e5bf12e19.zip |
Fix #3 by cleaning up a few localhost issues
-rw-r--r-- | index.php | 2 | ||||
-rw-r--r-- | loginform.inc.php (renamed from login.inc.php) | 3 | ||||
-rw-r--r-- | postform.inc.php | 3 | ||||
-rw-r--r-- | timeline.inc.php | 3 |
4 files changed, 7 insertions, 4 deletions
@@ -7,7 +7,7 @@ require_once(ROOT.DS.'single.inc.php'); } elseif(mb_strtolower(path(0)) === 'login') { // show login form - require_once(ROOT.DS.'login.inc.php'); + require_once(ROOT.DS.'loginform.inc.php'); } elseif(mb_strtolower(path(0)) === 'new') { if(isset($_COOKIE['microblog_login']) && $_COOKIE['microblog_login'] === sha1($config['url'].$config['admin_pass'])) { // show the post form diff --git a/login.inc.php b/loginform.inc.php index 775e08b..8a6cad8 100644 --- a/login.inc.php +++ b/loginform.inc.php @@ -4,7 +4,8 @@ // handle login if(isset($_POST['user']) && isset($_POST['pass'])) { if($_POST['user'] === $config['admin_user'] && $_POST['pass'] === $config['admin_pass']) { - setcookie('microblog_login', sha1($config['url'].$config['admin_pass']), NOW+$config['cookie_life']); + $domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false; + setcookie('microblog_login', sha1($config['url'].$config['admin_pass']), NOW+$config['cookie_life'], '/', $domain, false); header('Location: '.$config['url'].'/new'); die(); diff --git a/postform.inc.php b/postform.inc.php index 7d7f97e..417718c 100644 --- a/postform.inc.php +++ b/postform.inc.php @@ -4,7 +4,8 @@ // check user credentials if(isset($_COOKIE['microblog_login']) && $_COOKIE['microblog_login'] === sha1($config['url'].$config['admin_pass'])) { // correct auth data, extend cookie life - setcookie('microblog_login', sha1($config['url'].$config['admin_pass']), NOW+$config['cookie_life']); + $domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false; + setcookie('microblog_login', sha1($config['url'].$config['admin_pass']), NOW+$config['cookie_life'], '/', $domain, false); } else { // wrong data, kick user to login page header('HTTP/1.0 401 Unauthorized'); diff --git a/timeline.inc.php b/timeline.inc.php index 3b0581f..5932aa7 100644 --- a/timeline.inc.php +++ b/timeline.inc.php @@ -5,7 +5,8 @@ // check user credentials if(isset($_COOKIE['microblog_login']) && $_COOKIE['microblog_login'] === sha1($config['url'].$config['admin_pass'])) { // correct auth data, extend cookie life - setcookie('microblog_login', sha1($config['url'].$config['admin_pass']), NOW+$config['cookie_life']); + $domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false; + setcookie('microblog_login', sha1($config['url'].$config['admin_pass']), NOW+$config['cookie_life'], '/', $domain, false); } // pagination |