Example #1
0
 function __cleanupService()
 {
     if (isset($_ENV['SOFTHOOKS']['SHUTDOWN'])) {
         foreach ($_ENV['SOFTHOOKS']['SHUTDOWN'] as $hook) {
             executeUserParams($hook["FUNC"], $hook["OBJ"]);
         }
     }
     if (function_exists("runHooks")) {
         runHooks("serviceClose");
     }
     // saveSettings();
     // saveSiteSettings();
     saveSession();
     MetaCache::getInstance()->dumpAllCache();
     DataCache::getInstance()->dumpAllCache();
     Database::closeAll();
 }
/**
 * Persist the OAuth access token and session handle somewhere
 * In my example I am just using the session, but in real world, this is should be a storage engine
 *
 * @param array $params the response parameters as an array of key=value pairs
 */
function persistSession($response)
{
    if (isset($response)) {
        $_SESSION['access_token'] = $response['oauth_token'];
        $_SESSION['oauth_token_secret'] = $response['oauth_token_secret'];
        if (isset($response['oauth_session_handle'])) {
            $_SESSION['session_handle'] = $response['oauth_session_handle'];
        }
        $access_token = $response['oauth_token'];
        $access_secret = $response['oauth_token_secret'];
        if (isset($response['oauth_session_handle'])) {
            $session_handle = $response['oauth_session_handle'];
        } else {
            $session_handle = '';
        }
        $cb_id = saveSession($access_token, $access_secret);
        return $cb_id;
    } else {
        return false;
    }
}
Example #3
0
<!-- ********Author: Pooja, TingTing, Allan, Shubham @ Date: 2015 Fall ************-->
<?php 
if (session_status() == PHP_SESSION_NONE) {
    session_start();
}
include "../php_func/func.php";
if (isset($_SESSION['id'])) {
    saveSession();
}
session_unset();
session_destroy();
ini_set('display_errors', 'On');
?>
<!DocType html>
<html>
<head>
  <title>
    Leisurely | Logout page
  </title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

  <script src = "/lesuirely/js/event.js" text = "text/javascript" language = "javascript"></script>

  <link href="/lesuirely/css/styles.css" rel="stylesheet">
</head>
<body onload="getDate()">
Example #4
0
$cF = "&amp;cal={$calID}";
foreach ($_SESSION['cU'] as $usr) {
    if ($usr) {
        $cF .= '&amp;cU%5B%5D=' . $usr;
    }
}
foreach ($_SESSION['cC'] as $cat) {
    if ($cat) {
        $cF .= '&amp;cC%5B%5D=' . $cat;
    }
}
if ($cF) {
    $cF = '?' . substr($cF, 5);
}
if ((isset($_REQUEST['cP']) or isset($_REQUEST['cU']) or isset($_REQUEST['cC']) or isset($_POST['cL'])) and $_SESSION['uid'] > 1) {
    saveSession($sessID, $calID);
    //save session data to db
}
//page definitions
//page, header, no hdr, mob hdr, footer, mob ftr, title, retrieve required, spec. attributes
$pages = array('1' => array('views/year.php', '1', '0', 'm', '1', '0', '', 'y', ''), '2' => array('views/month.php', '1', '0', 'm', '1', '0', '', 'y', 'fm'), '3' => array('views/month.php', '1', '0', 'm', '1', '0', '', 'y', 'wm'), '4' => array('views/week.php', '1', '0', 'm', '1', '0', '', 'y', 'fw'), '5' => array('views/week.php', '1', '0', 'm', '1', '0', '', 'y', 'ww'), '6' => array('views/day.php', '1', '0', 'm', '1', '0', '', 'y', ''), '7' => array('views/upcoming.php', '1', '0', 'm', '1', '0', $xx['title_upcoming'], 'y', ''), '8' => array('views/changes.php', '1', '0', 'm', '1', '0', $xx['title_changes'], 'y', ''), '10' => array('pages/event.php', 'e', 'e', 'e', '0', '0', $xx['title_event'], '', ''), '11' => array('pages/eventcheck.php', 'e', 'e', 'e', '0', '0', $xx['title_check_event'], '', ''), '20' => array('pages/login.php', 'l', 'l', 'l', '1', '0', $xx['title_log_in'], '', ''), '21' => array('pages/search.php', 'a', 'a', 'a', '1', '0', $xx['title_search'], 'y', ''), '22' => array('lang/ug-' . strtolower($_SESSION['cL']) . '.php', 'h', 'h', 'h', '0', '0', $xx['title_user_guide'], '', ''), '90' => array('pages/settings.php', 'a', 'a', 'a', '1', '0', $xx['title_settings'], '', ''), '91' => array('pages/categories.php', 'a', 'a', 'a', '1', '0', $xx['title_edit_cats'], '', ''), '92' => array('pages/users.php', 'a', 'a', 'a', '1', '0', $xx['title_edit_users'], '', ''), '93' => array('pages/database.php', 'a', 'a', 'a', '1', '0', $xx['title_manage_db'], '', ''), '94' => array('pages/importICS.php', 'a', 'a', 'a', '1', '0', $xx['title_ics_import'], '', ''), '95' => array('pages/exportICS.php', 'a', 'a', 'a', '1', '0', $xx['title_ics_export'], 'y', ''), '96' => array('pages/importCSV.php', 'a', 'a', 'a', '1', '0', $xx['title_csv_import'], '', ''));
if (!array_key_exists($_SESSION['cP'], $pages)) {
    $_SESSION['cP'] = $set['defaultView'];
}
//validate cP
$mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : $pages[$cP][8];
//get mode
$pageTitle = $pages[$cP][6];
//echo "LuxCal version: ".LCV."<br>"; print_r($set); die;//TEST LINE
if ($pages[$cP][7]) {
    //retrieve required
Example #5
0
/**
 * userLogin function
 * this fucntion do the operation for Loggin into the site into the frontend, 
 * it will allow the arvind it user, brand user, distribiutors and the dealers only,
 * the key feature of the fucntion is, it will not allow multiple session of the same user, it will make an entry in the database in the sessions tables for the particluar user in front of ip of the user is using.
 * the user login from multiple browsers i.e only from the same i.p address, a user must log out to delete the previous session.
 * this function can called by the ajax method from the admin panel or from the front end as well, using action cammand rw_login
 * 
 * @return void
 * @author Ankit Balyan - sf.ankit@gmail.com
 **/
function userLogin()
{
    extract($_POST);
    global $wpdb;
    $table = 'rw_users';
    if (isset($user_id) && $user_id != '' && isset($user_password) && $user_password != '') {
        $user_password = sha1(trim($user_password));
        $sql = "SELECT * FROM {$table} where user_name = '{$user_id}' and user_password = '******' and user_actv_ind = 1";
        $user = $wpdb->get_row($sql);
        if (count($user)) {
            $sql = "SELECT * FROM `sessions` where access_id = {$user->user_id}";
            $session_exist = $wpdb->get_row($sql);
            if ($session_exist) {
                session_start();
                if ($session_exist->session_id == session_id() || $session_exist->ip_addr == getIp()) {
                    session_regenerate_id(true);
                    $_SESSION['user_id'] = $user->user_id;
                    $sid = session_id();
                    if ($sid) {
                        if (saveSession($user->user_id)) {
                            echo "Validate Successfully, Lets go to Home Page";
                        }
                    }
                    die;
                } else {
                    unset($_SESSION);
                    session_destroy();
                    echo "You are being already logged in from another device";
                    die;
                }
                exit;
            } elseif (isset($user->user_id) && $user->user_id) {
                session_start();
                session_regenerate_id(true);
                $_SESSION['user_id'] = $user->user_id;
                $sid = session_id();
                if ($sid) {
                    if (saveSession()) {
                        echo "Validate Successfully, Lets go to Home Page";
                    }
                }
            }
        } else {
            sleep(2);
            echo "Either user Id or password is Invalid";
        }
    } else {
        sleep(2);
        echo "Invalid Credentials Details";
    }
    die;
}
Example #6
0
/**
* remove unmatched records from import data
*
* @param mixed $session_id
* @param mixed $idfield
*/
function delete_unmatched_records($session_id, $idfield)
{
    global $mysqli;
    $session = get_import_session($mysqli, $session_id);
    if (!is_array($session)) {
        print $session;
        return;
    }
    $import_table = $session['import_table'];
    $query = " DELETE FROM " . $import_table . " WHERE " . $idfield . "<0";
    $res = $mysqli->query($query);
    if ($res) {
        //read content of tempfile and send it to client
        print $mysqli->affected_rows;
        $query = " SELECT count(*) FROM " . $import_table;
        $row = mysql__select_array2($mysqli, $query);
        if ($row && $row[0] > 0) {
            $session['reccount'] = $row[0];
            saveSession($mysqli, $session);
        }
    } else {
        print "SQL error: " . $mysqli->error;
    }
}
Example #7
0
function login($email, $password)
{
    $return = returnValue();
    getDBCredentials('L');
    if (empty($email) || empty($password)) {
        $return->value = false;
        $return->msg = "You need to enter email and password";
        return $return;
    }
    $password = hash('sha256', $password);
    $login = selectByEmailAndPassword($email, $password);
    if (!$login) {
        $return->value = false;
        $return->msg = "Invalid login credentials";
        throttleAccess('login');
        return $return;
    }
    // save user to session
    $firstname = $login->FIRST_NAME;
    $lastname = $login->LAST_NAME;
    $userid = $login->ID;
    $usertype = $login->USER_TYPE;
    saveSession($email, $usertype, $firstname, $lastname, $userid);
    $return->value = true;
    $return->msg = "Login successful";
    return $return;
}
<?php

$file = '../jsonDB/admins.json';
$sessions = '../jsonDB/sessions.json';
$method = '';
if (isset($_POST['method'])) {
    $method = $_POST['method'];
}
if ($method == 'saveAdmin') {
    saveAdmin($file);
} else {
    if ($method == 'saveSession') {
        saveSession($sessions);
    } else {
        if ($method == 'deleteSession') {
            deleteSession($sessions);
        }
    }
}
function saveAdmin($file)
{
    $eventJSON = filter_input(INPUT_POST, 'json');
    file_put_contents($file, $eventJSON);
    $responseArray['status'] = 'success';
    echo json_encode($responseArray);
}
function saveSession($file)
{
    $data = filter_input(INPUT_POST, 'data');
    $jsonInPHP = json_decode(file_get_contents($file));
    array_push($jsonInPHP->sessions, $data);
Example #9
0
/**
* MAIN method for first step - finding exisiting /matching records in destination
* Assign record ids to field in import table
* (negative if not found)
*
* since we do match and assign in ONE STEP - first we call findRecordIds
*
* @param mixed $mysqli
* @param mixed $imp_session
* @param mixed $params
* @return mixed
*/
function assignRecordIds($params)
{
    global $system;
    //get rectype to import
    $rty_ID = @$params['sa_rectype'];
    $currentSeqIndex = @$params['seq_index'];
    if (intval($rty_ID) < 1 || !(intval($currentSeqIndex) >= 0)) {
        $system->addError(HEURIST_INVALID_REQUEST, 'Record type not defined or wrong value');
        return false;
    }
    $imp_session = getImportSession($params['imp_ID']);
    if (is_bool($imp_session) && !$imp_session) {
        return false;
        //error - can not get import session
    }
    //error_log(print_r($imp_session,true));
    //error_log(print_r($params,true));
    $imp_session = findRecordIds($imp_session, $params);
    if (is_array($imp_session)) {
        $records = $imp_session['validation']['records'];
        //imp_id(line#) => list of records ids
        $pairs = $imp_session['validation']['pairs'];
        //keyvalues => record id - count number of unique values
        $disambiguation = $imp_session['validation']['disambiguation'];
    } else {
        return $imp_session;
        //error
    }
    //keep counts
    if (!@$imp_session['sequence'][$currentSeqIndex]['counts']) {
        $imp_session['sequence'][$currentSeqIndex]['counts'] = array();
    }
    if (count($disambiguation) > 0) {
        return $imp_session;
        //"It is not possible to proceed because of disambiguation";
    }
    $import_table = $imp_session['import_table'];
    $mysqli = $system->get_mysqli();
    $id_fieldname = @$params['idfield'];
    $id_field = null;
    $field_count = count($imp_session['columns']);
    if (!$id_fieldname || $id_fieldname == "null") {
        $id_fieldname = $imp_session['sequence'][$currentSeqIndex]['field'];
        //$rectype = dbs_GetRectypeByID($mysqli, $rty_ID);
        //$id_fieldname = $rectype['rty_Name'].' ID'; //not defined - create new identification field
    }
    $index = array_search($id_fieldname, $imp_session['columns']);
    //find it among existing columns
    if ($index !== false) {
        //this is existing field
        $id_field = "field_" . $index;
        $imp_session['uniqcnt'][$index] = count($pairs);
    }
    //add new field into import table
    if (!$id_field) {
        $id_field = "field_" . $field_count;
        $altquery = "alter table " . $import_table . " add column " . $id_field . " varchar(255) ";
        if (!$mysqli->query($altquery)) {
            $system->addError(HEURIST_DB_ERROR, 'Cannot alter import session table; cannot add new index field', $mysqli->error);
            return false;
        }
        /*
                $altquery = "update ".$import_table." set ".$id_field."=-1 where imp_id>0";
                if (!$mysqli->query($altquery)) {
                    $system->addError(HEURIST_DB_ERROR, 'Cannot set new index field', $mysqli->error);
                    return false;
                }*/
        array_push($imp_session['columns'], $id_fieldname);
        array_push($imp_session['uniqcnt'], count($pairs) > 0 ? count($pairs) : $imp_session['reccount']);
        if (@$params['idfield']) {
            array_push($imp_session['multivals'], $field_count);
            //!!!!
        }
    }
    if (count($records) > 0) {
        //update ID values in import table - repalce id to found
        foreach ($records as $imp_id => $ids) {
            if ($ids) {
                //update
                $updquery = "update " . $import_table . " set " . $id_field . "='" . $ids . "' where imp_id = " . $imp_id;
                if (!$mysqli->query($updquery)) {
                    $system->addError(HEURIST_DB_ERROR, 'Cannot update import table: set ID field', $mysqli->error . ' QUERY:' . $updquery);
                    return false;
                }
            }
        }
    } else {
        //find records to insert and update if matching is skipped
        // find records to update
        $select_query = "SELECT count(DISTINCT " . $id_field . ") FROM " . $import_table . " left join Records on rec_ID=" . $id_field . " WHERE rec_ID is not null and " . $id_field . ">0";
        $cnt = mysql__select_value($mysqli, $select_query);
        if ($cnt > 0) {
            $imp_session['validation']['count_update'] = $cnt;
            $imp_session['validation']['count_update_rows'] = $cnt;
            /*
            //find first 100 records to display
            $select_query = "SELECT ".$id_field.", imp_id FROM ".$import_table
            ." left join Records on rec_ID=".$id_field
            ." WHERE rec_ID is not null and ".$id_field.">0"
            ." ORDER BY ".$id_field." LIMIT 5000";
            $imp_session['validation']['recs_update'] = mysql__select_all($mysqli, $select_query);
            */
            $imp_session['validation']['recs_update'] = array();
            //do not send all records to client side
        }
        // find records to insert
        $select_query = "SELECT count(DISTINCT " . $id_field . ") FROM " . $import_table . " WHERE " . $id_field . "<0";
        $cnt = mysql__select_value($mysqli, $select_query);
        $select_query = "SELECT count(*) FROM " . $import_table . " WHERE " . $id_field . " IS NULL";
        $cnt2 = mysql__select_value($mysqli, $select_query);
        $cnt = $cnt + ($cnt2 > 0 ? intval($cnt2) : 0);
        if ($cnt > 0) {
            $imp_session['validation']['count_insert'] = $cnt;
            $imp_session['validation']['count_insert_rows'] = $cnt;
            /*
            //find first 100 records to display
            $select_query = "SELECT imp_id FROM ".$import_table
                    .' WHERE '.$id_field.'<0 or '.$id_field.' IS NULL LIMIT 5000';
            $imp_session['validation']['recs_insert'] = mysql__select_all($mysqli, $select_query);
            */
            $imp_session['validation']['recs_insert'] = array();
            //do not send all records to client side
        }
        //$imp_session['validation']['count_insert'] = $imp_session['reccount'];
    }
    //define field as index in session
    @($imp_session['indexes'][$id_field] = $rty_ID);
    //to keep mapping for index field
    if (!@$imp_session['sequence'][$currentSeqIndex]['mapping_keys']) {
        $imp_session['sequence'][$currentSeqIndex]['mapping_keys'] = array();
    }
    if (@$params['skip_match'] != 1) {
        $imp_session['sequence'][$currentSeqIndex]['mapping_keys'] = @$params['mapping'];
    }
    $imp_session['sequence'][$currentSeqIndex]['counts'] = array($imp_session['validation']['count_update'], $imp_session['validation']['count_update_rows'], $imp_session['validation']['count_insert'], $imp_session['validation']['count_insert_rows']);
    $ret_session = $imp_session;
    unset($imp_session['validation']);
    //save session without validation info
    saveSession($imp_session);
    return $ret_session;
}
Example #10
0
function postmode_file_load_to_db($filename, $original, $is_preprocess)
{
    global $mysqli;
    //$val_separator = $_REQUEST["val_separator"];
    $csv_mvsep = $_REQUEST["csv_mvsep"];
    $csv_delimiter = $_REQUEST["csv_delimiter"];
    $csv_encoding = $_REQUEST["csv_encoding"];
    $csv_linebreak = $_REQUEST["csv_linebreak"];
    $csv_enclosure = $_REQUEST["csv_enclosure"] == 1 ? "'" : '"';
    if ($csv_delimiter == "tab") {
        $csv_delimiter = "\t";
    }
    if ($csv_linebreak == "auto") {
        ini_set('auto_detect_line_endings', true);
        $lb = null;
    } else {
        $lb = str_replace("\\n", "\n", $csv_linebreak);
        $lb = str_replace("\\r", "\r", $lb);
        $lb = str_replace("\\t", "\t", $lb);
    }
    $handle = @fopen($filename, "r");
    if (!$handle) {
        if (!file_exists($filename)) {
            return 'file does not exist';
        } else {
            if (!is_readable($filename)) {
                return 'file is not readable';
            } else {
                return 'file could not be read';
            }
        }
    }
    //fgetcsv и str_getcsv depends on server locale
    // it is possible to set it in  /etc/default/locale (Debian) or /etc/sysconfig/i18n (CentOS)  LANG="en_US.UTF-8"
    setlocale(LC_ALL, 'en_US.utf8');
    // read header
    if ($csv_linebreak == "auto") {
        $line = fgets($handle, 1000000);
    } else {
        $line = stream_get_line($handle, 1000000, $lb);
    }
    fclose($handle);
    if (!$line) {
        return "Empty header line";
    }
    //detect encoding and convert to UTF8
    if ($csv_encoding != 'UTF-8' || !mb_check_encoding($line, 'UTF-8')) {
        $line = mb_convert_encoding($line, 'UTF-8', $csv_encoding);
        if (!$line) {
            return 'Your file can\'t be converted to UTF-8. ' . 'Please open it in any advanced editor and save with UTF-8 text encoding';
        }
        $content = file_get_contents($filename);
        $content = mb_convert_encoding($content, 'UTF-8');
        if (!$content) {
            return 'Your file can\'t be converted to UTF-8. ' . 'Please open it in any advanced editor and save with UTF-8 text encoding';
        }
        $res = file_put_contents($filename, $content);
        if (!$res) {
            return 'Cant save temporary file ' . $filename;
        }
    }
    //  mb_detect_encoding($line, "UTF-8, ISO-8859-1, ISO-8859-15", true);
    //get fields
    $fields = str_getcsv($line, $csv_delimiter, $csv_enclosure);
    // $escape = "\\"
    $len = count($fields);
    if ($len > 200) {
        return "Too many columns " . $len . "  This probably indicates that you have selected the wrong separator type.";
    }
    if ($is_preprocess) {
        if (strpos($filename, HEURIST_FILESTORE_DIR . 'scratch/') === 0) {
            $temp_file = $filename;
            $ok_moved = true;
        } else {
            $temp_file = tempnam(HEURIST_SCRATCHSPACE_DIR, $filename);
            $ok_moved = move_uploaded_file($filename, $temp_file);
        }
        if ($ok_moved) {
            if ($len == 1) {
                return array("warning" => "You appear to have only one value per line. This probably indicates that " . "you have selected the wrong separator type.", "filename" => $temp_file, "original" => $original, "fields" => $fields);
            } else {
                return array("warning" => "Please verify the list of columns", "filename" => $temp_file, "original" => $original, "fields" => $fields);
            }
        } else {
            return "Failed to keep the uploaded file '{$temp_file}'.";
            //array("fatal_error"=>"Failed to keep the uploaded file '$temp_file'.");
        }
    }
    //array( "filename"=>$temp_name, "errors"=>$errors, "memos"=>$memos, "multivals"=>$multivals )
    $preproc = preprocess_uploaded_file($filename);
    if (count($preproc['errors']) > 0 || count($preproc['err_encoding']) > 0) {
        return array("errors" => $preproc['errors'], "col_count" => $preproc['col_count'], "fields" => $preproc['fields'], "err_encoding" => $preproc['err_encoding']);
    }
    $filename = $preproc['filename'];
    $import_table = "import" . date("YmdHis");
    //create temporary table import_datetime
    $query = "CREATE TABLE `" . $import_table . "` (`imp_ID` int(10) unsigned NOT NULL AUTO_INCREMENT, ";
    $columns = "";
    $counts = "";
    $mapping = array();
    for ($i = 0; $i < $len; $i++) {
        $query = $query . "`field_" . $i . "` " . (in_array($i, $preproc['memos']) ? " mediumtext, " : " varchar(300), ");
        $columns = $columns . "field_" . $i . ",";
        $counts = $counts . "count(distinct field_" . $i . "),";
        //array_push($mapping,0);
    }
    $query = $query . " PRIMARY KEY (`imp_ID`)) ENGINE=InnoDB  DEFAULT CHARSET=utf8;";
    $columns = substr($columns, 0, -1);
    $counts = $counts . " count(*) ";
    if (!$mysqli->query($query)) {
        return "cannot create table: " . $mysqli->error;
    }
    if ($csv_enclosure == "'") {
        $csv_enclosure = "\\" . $csv_enclosure;
    }
    if (strpos($filename, "\\") > 0) {
        $filename = str_replace("\\", "\\\\", $filename);
    }
    //load file into table  LOCAL
    $query = "LOAD DATA LOCAL INFILE '" . $filename . "' INTO TABLE " . $import_table . " CHARACTER SET UTF8" . " FIELDS TERMINATED BY '" . $csv_delimiter . "' " . " OPTIONALLY ENCLOSED BY '" . $csv_enclosure . "' " . " LINES TERMINATED BY '\n'" . " (" . $columns . ")";
    if (!$mysqli->query($query)) {
        return 'Unable to import data. MySQL command: "' . $query . '" returns error: ' . $mysqli->error;
    }
    $warnings = array();
    if ($info = $mysqli->info) {
        if ($mysqli->warning_count) {
            array_push($warnings, $info);
            $e = $mysqli->get_warnings();
            do {
                array_push($warnings, $e->message);
                //$e->errno.": ".
            } while ($e->next());
        }
        /*if(strpos("$info", "Warnings: 0")===false){
          $mysqli->query("SHOW WARNINGS");
          }*/
    }
    if (!$is_preprocess && file_exists($filename)) {
        unlink($filename);
    }
    //calculate uniqe values
    $query = "select " . $counts . " from " . $import_table;
    $res = $mysqli->query($query);
    if (!$res) {
        return "cannot count unique values: " . $mysqli->error;
    }
    $uniqcnt = $res->fetch_row();
    $reccount = array_pop($uniqcnt);
    //add record to import_log
    $session = array("reccount" => $reccount, "import_table" => $import_table, "import_name" => $original . "  " . date("Y-m-d H:i:s"), "columns" => $fields, "memos" => $preproc['memos'], "multivals" => $preproc['multivals'], "csv_enclosure" => $_REQUEST['csv_enclosure'], "csv_mvsep" => $_REQUEST['csv_mvsep'], "uniqcnt" => $uniqcnt, "mapping" => $mapping, "indexes" => array());
    //names of columns in importtable that contains record_ID
    $session = saveSession($mysqli, $session);
    if (count($warnings) > 0) {
        $session['load_warnings'] = $warnings;
    }
    return $session;
}