-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9d8f915
Showing
14 changed files
with
1,388 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
config.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
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,42 @@ | ||
<?php | ||
|
||
class Auth_SessionAuth implements Auth_Template | ||
{ | ||
public function start($sessionID, $userIDKey = 'userID', $cookieName = 'TRNSSESS') | ||
{ | ||
if (session_id() == "") { | ||
if (!empty($sessionID)) { | ||
session_id($sessionID); | ||
} | ||
if (isset($config['cookieName'])) { | ||
ini_set('session.name', $config['cookieName']); | ||
} | ||
session_start(); | ||
} | ||
if (!isset($config['userIDKey'])) { | ||
throw new Exception("TranslationAuth cannot load userID from session without a specified userIDKey!"); | ||
} | ||
$user = array('userID' => null, | ||
'username' => null, | ||
); | ||
$key = $config['userIDKey']; | ||
if (isset($_SESSION[$key])) { | ||
$user['userID'] = $_SESSION[$key]; | ||
} | ||
return $user; | ||
} | ||
|
||
public function login($username, $password) | ||
{ | ||
$db = TranslationDB::getInstance(); | ||
//todo: login? | ||
} | ||
|
||
public function logout() | ||
{ | ||
session_destroy(); | ||
return true; | ||
} | ||
} | ||
|
||
//EOF |
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,25 @@ | ||
<?php | ||
|
||
interface Auth_Template | ||
{ | ||
public function __construct(); | ||
|
||
/** | ||
* @return array (userID => int|string, username => string) | ||
*/ | ||
public function start($sessionID); | ||
|
||
/** | ||
* $password is NOT hashed | ||
* | ||
* @return array (userID => int|string, username => string) | ||
*/ | ||
public function login($username, $password); | ||
|
||
/** | ||
* @return bool success | ||
*/ | ||
public function logout(); | ||
} | ||
|
||
//EOF |
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,2 @@ | ||
* | ||
!.gitignore |
Oops, something went wrong.