-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Coral-erm/pr68
Session abstraction (Pr68 on previous repo)
- Loading branch information
Showing
16 changed files
with
77 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
class CoralSession | ||
{ | ||
private static $opened; | ||
|
||
private static function open_for_read() { | ||
if (!isset(self::$opened)) { | ||
session_start(); | ||
session_write_close(); | ||
self::$opened = true; | ||
} | ||
} | ||
|
||
public static function get($key) { | ||
self::open_for_read(); | ||
if (isset($_SESSION[$key])) { | ||
return $_SESSION[$key]; | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
public static function set($key, $value) { | ||
session_start(); | ||
$_SESSION[$key] = $value; | ||
session_write_close(); | ||
self::$opened = true; | ||
} | ||
|
||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,6 @@ | |
*/ | ||
|
||
|
||
session_start(); | ||
|
||
include_once 'directory.php'; | ||
include_once 'util.php'; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,26 +18,23 @@ | |
*/ | ||
|
||
|
||
session_start(); | ||
|
||
include_once 'directory.php'; | ||
|
||
//print header | ||
$pageTitle=_('Home'); | ||
include 'templates/header.php'; | ||
|
||
//used for creating a "sticky form" for back buttons | ||
//except we don't want it to retain if they press the 'index' button | ||
//check what referring script is | ||
|
||
if ($_SESSION['ref_script'] != "resource.php"){ | ||
if (CoralSession::get('ref_script') != "resource.php"){ | ||
Resource::resetSearch(); | ||
} | ||
|
||
CoralSession::set('ref_script', $currentPage); | ||
$search = Resource::getSearch(); | ||
|
||
$_SESSION['ref_script']=$currentPage; | ||
|
||
//print header | ||
$pageTitle=_('Home'); | ||
include 'templates/header.php'; | ||
|
||
|
||
?> | ||
|
@@ -614,24 +611,24 @@ | |
<script type="text/javascript" src="js/index.js"></script> | ||
<script type='text/javascript'> | ||
<?php | ||
//used to default to previously selected values when back button is pressed | ||
//if the startWith is defined set it so that it will default to the first letter picked | ||
if ((isset($_SESSION['res_startWith'])) && ($reset != 'Y')){ | ||
echo "startWith = '" . $_SESSION['res_startWith'] . "';"; | ||
echo "$(\"#span_letter_" . $_SESSION['res_startWith'] . "\").removeClass('searchLetter').addClass('searchLetterSelected');"; | ||
} | ||
|
||
if ((isset($_SESSION['res_pageStart'])) && ($reset != 'Y')){ | ||
echo "pageStart = '" . $_SESSION['res_pageStart'] . "';"; | ||
} | ||
|
||
if ((isset($_SESSION['res_recordsPerPage'])) && ($reset != 'Y')){ | ||
echo "recordsPerPage = '" . $_SESSION['res_recordsPerPage'] . "';"; | ||
} | ||
|
||
if ((isset($_SESSION['res_orderBy'])) && ($reset != 'Y')){ | ||
echo "orderBy = \"" . $_SESSION['res_orderBy'] . "\";"; | ||
} | ||
//used to default to previously selected values when back button is pressed | ||
//if the startWith is defined set it so that it will default to the first letter picked | ||
if ((CoralSession::get('res_startWith')) && ($reset != 'Y')){ | ||
echo "startWith = '" . CoralSession::get('res_startWith') . "';"; | ||
echo "$(\"#span_letter_" . CoralSession::get('res_startWith') . "\").removeClass('searchLetter').addClass('searchLetterSelected');"; | ||
} | ||
|
||
if ((CoralSession::get('res_pageStart')) && ($reset != 'Y')){ | ||
echo "pageStart = '" . CoralSession::get('res_pageStart') . "';"; | ||
} | ||
|
||
if ((CoralSession::get('res_recordsPerPage')) && ($reset != 'Y')){ | ||
echo "recordsPerPage = '" . CoralSession::get('res_recordsPerPage') . "';"; | ||
} | ||
|
||
if ((CoralSession::get('res_orderBy')) && ($reset != 'Y')){ | ||
echo "orderBy = \"" . CoralSession::get('res_orderBy') . "\";"; | ||
} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jsavell
Author
Contributor
|
||
|
||
echo "</script>"; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
<?php | ||
session_start(); | ||
|
||
include_once '../directory.php'; | ||
include_once '../user.php'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 comment
on commit 44d4880
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot, notices about the already started sessions represented about 10% of the noise that was in the logs. Hopefully none of these will remain :-D
@jsavell
Watch out for your text editor settings, it replaced tabs (which are 90% of the indentation of Coral) by two spaces indents.