| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- //Functie om user variable te controlleren en te strippen
- function safeString($var){
- $TEMPSTRING = $var;
- $TEMPSTRING = strip_tags($TEMPSTRING);
- $TEMPSTRING = htmlspecialchars($TEMPSTRING);
- $TEMPSTRING = trim($TEMPSTRING);
- return $TEMPSTRING;
- }
-
- //Session management
- function destroySession(){
- setcookie('session', '', 0);
- }
-
- function setSession($session_id){
- setcookie('session', base64_encode($session_id), time()+60*60*24*365);
- }
-
- function getSession(){
- if(isset($_COOKIE['session'])){
- return base64_decode($_COOKIE['session']);
- }
- else{
- return false;
- }
- }
-
- function isSession(){
- return isset($_COOKIE['session']);
- }
- function reDirect($url){
- echo '<script type="text/javascript">window.location.href = \''.$url.'\';</script> ';
- }
- //Log out
- function logout($error){
- global $mysqli;
- if($error!='verify' && $error!='expired' && $error!='email' && $error!='nomail' && $error!='forgot'){
- if($error!='nosession'){
- $session_id = $_SESSION['id'];
- if(isset($session_id)){
- if($stmt1 = $mysqli -> prepare("UPDATE `login` SET `ip`=?, `session_id`=? WHERE `session_id`=? ")) {
- $stmt1 -> bind_param('sss', "", "", $session_id);
- $stmt1 -> execute();
- $stmt1 -> close();
- }
- }
- }
- destroySession();
- }
- $link = "login.php?" . $error;
- die(header("Location: $link"));
- }
-
-
|