Skip to content

Commit

Permalink
Capitalize Timeout param for consistency, trim redirect function (Chu…
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwen committed Feb 12, 2016
1 parent 5f33923 commit ad00c50
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
4 changes: 2 additions & 2 deletions churchinfo/Default.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
// Initialize the variables

// Is the user requesting to logoff or timed out?
if (isset($_GET["Logoff"]) || isset($_GET['timeout'])) {
if (isset($_GET["Logoff"]) || isset($_GET['Timeout'])) {
if (!isset($_SESSION['sshowPledges']) || ($_SESSION['sshowPledges'] == ''))
$_SESSION['sshowPledges'] = 0;
if (!isset($_SESSION['sshowPayments']) || ($_SESSION['sshowPayments'] == ''))
Expand Down Expand Up @@ -331,7 +331,7 @@
<p class="login-box-msg"><?= gettext('Please Login'); ?></p>

<?php
if (isset($_GET['timeout']))
if (isset($_GET['Timeout']))
$loginPageMsg = "Your previous session timed out. Please login again.";

// output warning and error messages
Expand Down
32 changes: 14 additions & 18 deletions churchinfo/Include/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
{
if ((time() - $_SESSION['tLastOperation']) > $sSessionTimeout)
{
Redirect("Default.php?timeout");
Redirect("Default.php?Timeout");
exit;
}
else {
Expand Down Expand Up @@ -269,12 +269,6 @@ function RedirectURL($sRelativeURL)
global $sRootPath;
global $sDocumentRoot;

if (!isset($_SESSION['sRootPath']))
{
header('Location: Default.php?timeout');
exit;
}

// Test if file exists before redirecting. May need to remove
// query string first.
$iQueryString = strpos($sRelativeURL, '?');
Expand All @@ -285,21 +279,23 @@ function RedirectURL($sRelativeURL)
}

// The idea here is to get the file path into this form:
// $sFullPath = $sDocumentRoot.$sRootPath.$sPathExtension
// $sFullPath = $sDocumentRoot . $sRootPath . $sPathExtension
// The Redirect URL is then in this form:
// $sRedirectURL = $_SESSION['sRootPath'].$sPathExtension

// $sRedirectURL = $sRootPath . $sPathExtension
$sFullPath = str_replace('\\', '/', $sDocumentRoot . '/' . $sPathExtension);

// With the query string removed we can test if file exists
if (file_exists($sFullPath) && is_readable($sFullPath)) {
return ($_SESSION['sRootPath'] . '/' . $sRelativeURL);
} else {
$sErrorMessage = 'Fatal Error: Cannot access file: '.$sFullPath."<br>\n";
$sErrorMessage .= "\$sPathExtension = $sPathExtension<br>\n";
$sErrorMessage .= "\$sDocumentRoot = $sDocumentRoot<br>\n";
$sErrorMessage .= "\$_SESSION['sRootPath'] = ";
$sErrorMessage .= $_SESSION['sRootPath'] . "<br>\n";
if (file_exists($sFullPath) && is_readable($sFullPath))
{
return ($sRootPath . '/' . $sRelativeURL);
}
else
{
$sErrorMessage = 'Fatal Error: Cannot access file: '.$sFullPath."<br>\n"
. "\$sPathExtension = $sPathExtension<br>\n"
. "\$sDocumentRoot = $sDocumentRoot<br>\n"
. "\$_SESSION['sRootPath'] = "
. $sRootPath . "<br>\n";

die ($sErrorMessage);
}
Expand Down
2 changes: 1 addition & 1 deletion churchinfo/Include/Initialize.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
if ($sSessionTimeout > 0)
{
if ((time() - $_SESSION['tLastOperation']) > $sSessionTimeout) {
Redirect("Default.php?timeout");
Redirect("Default.php?Timeout");
exit;
} else {
$_SESSION['tLastOperation'] = time();
Expand Down

0 comments on commit ad00c50

Please sign in to comment.