diff options
author | Chad Little <clittle@users.sourceforge.net> | 2003-11-24 01:29:17 +0000 |
---|---|---|
committer | Chad Little <clittle@users.sourceforge.net> | 2003-11-24 01:29:17 +0000 |
commit | 323c110cb7787a09c175594001e2ba16674d9c50 (patch) | |
tree | 27cb9a6bcf650ca9f184c5a505a8fc4b572a4ae8 /functions | |
parent | 2d2a0f5bc3b8ec9b756412da4228128afdf5d9da (diff) | |
download | phpicalendar-323c110cb7787a09c175594001e2ba16674d9c50.tar.gz phpicalendar-323c110cb7787a09c175594001e2ba16674d9c50.tar.bz2 phpicalendar-323c110cb7787a09c175594001e2ba16674d9c50.zip |
Made some changed to user:pass system to be more auto configuring, and
now cookies work as well, as well as fixing subscribe and download links.
Diffstat (limited to 'functions')
-rw-r--r-- | functions/init.inc.php | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/functions/init.inc.php b/functions/init.inc.php index c2ce6a8..7661184 100644 --- a/functions/init.inc.php +++ b/functions/init.inc.php @@ -23,6 +23,10 @@ if (isset($HTTP_COOKIE_VARS['phpicalendar'])) { if (isset($phpicalendar['cookie_time'])) $day_start = $phpicalendar['cookie_time']; } +if ($cookie_uri == '') { + $cookie_uri = $HTTP_SERVER_VARS['SERVER_NAME'].substr($HTTP_SERVER_VARS['PHP_SELF'],0,strpos($HTTP_SERVER_VARS['PHP_SELF'], '/')); +} + // Look for a login cookie. unset($username, $password); if (isset($HTTP_COOKIE_VARS['phpicalendar_login'])) { @@ -38,11 +42,8 @@ if (isset($HTTP_GET_VARS['password'])) $password = $HTTP_GET_VARS['password']; else if (isset($HTTP_POST_VARS['password'])) $password = $HTTP_POST_VARS['password']; // Set the login cookie if logging in. Clear it if logging out. -if (isset($HTTP_GET_VARS['action'])) { - $action = $HTTP_GET_VARS['action']; -} else { - $action = ''; -} +$action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : ''; + if ($action == 'login') { $the_cookie = serialize(array('username' => $username, 'password' => $password)); setcookie('phpicalendar_login', $the_cookie, time()+(60*60*24*7*12*10), '/', $cookie_uri, 0); @@ -133,10 +134,10 @@ if ($is_webcal) { } // Sets the download and subscribe paths from the config if present. - if ($download_uri == '' && preg_match('/(^\/|..\/)/', $filename) == 0) { + if ($download_uri == '') { $subscribe_path = 'webcal://'.$HTTP_SERVER_VARS['SERVER_NAME'].dirname($HTTP_SERVER_VARS['PHP_SELF']).'/'.$filename; $download_filename = $filename; - } else if ($download_uri != '') { + } elseif ($download_uri != '') { $newurl = eregi_replace("^(http://)", "", $download_uri); $subscribe_path = 'webcal://'.$newurl.'/'.$cal_filename.'.ics'; $download_filename = $download_uri.'/'.$cal_filename.'.ics'; |