Exemplo n.º 1
0
bindtextdomain($domain, ELAB_ROOT . "locale");
textdomain($domain);
// END i18n
// run the update script if we have the wrong schema version
$update = new \Elabftw\Elabftw\Update();
// don't run it if we didn't run the update.php script yet
if (!is_null(get_config('schema'))) {
    if (get_config('schema') < $update::REQUIRED_SCHEMA) {
        try {
            $_SESSION['infos'] = $update->runUpdateScript();
        } catch (Exception $e) {
            $_SESSION['errors'] = $e->getMessage();
        }
    }
}
$user = new \Elabftw\Elabftw\User();
// pages where you don't need to be logged in
// reset.php is in fact app/reset.php but we use basename so...
$nologin_arr = array('login.php', 'login-exec.php', 'register.php', 'register-exec.php', 'change-pass.php', 'reset.php');
if (!isset($_SESSION['auth']) && !in_array(basename($_SERVER['SCRIPT_FILENAME']), $nologin_arr)) {
    // try to login with the cookie
    if (!$user->loginWithCookie()) {
        // maybe we clicked an email link and we want to be redirected to the page upon successful login
        // so we store the url in a cookie expiring in 5 minutes to redirect to it after login
        $host = $_SERVER['HTTP_HOST'];
        $script = $_SERVER['SCRIPT_NAME'];
        $params = '?' . $_SERVER['QUERY_STRING'];
        $url = 'https://' . $host . $script . $params;
        // remove trailing ? if there was no query string
        $url = rtrim($url, '?');
        setcookie('redirect', $url, time() + 300, '/', null, true, true);
Exemplo n.º 2
0
*    eLabFTW is distributed in the hope that it will be useful,                 *
*    but WITHOUT ANY WARRANTY; without even the implied                         *
*    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR                    *
*    PURPOSE.  See the GNU Affero General Public License for more details.      *
*                                                                               *
*    You should have received a copy of the GNU Affero General Public           *
*    License along with eLabFTW.  If not, see <http://www.gnu.org/licenses/>.   *
*                                                                               *
********************************************************************************/
require_once '../inc/common.php';
// INFO BOX
$msg_arr = array();
$errflag = false;
$wantUpdatePassword = false;
$tab = '1';
$user = new \Elabftw\Elabftw\User();
// TAB 1 : PREFERENCES
if (isset($_POST['display'])) {
    if ($_POST['display'] === 'default') {
        $new_display = 'default';
    } elseif ($_POST['display'] === 'compact') {
        $new_display = 'compact';
    } else {
        $new_display = 'default';
    }
    // ORDER
    if ($_POST['order'] === 'date' || $_POST['order'] === 'id' || $_POST['order'] === 'title') {
        $new_order = $_POST['order'];
    } else {
        $new_order = 'id';
    }
Exemplo n.º 3
0
*    eLabFTW is free software: you can redistribute it and/or modify            *
*    it under the terms of the GNU Affero General Public License as             *
*    published by the Free Software Foundation, either version 3 of             *
*    the License, or (at your option) any eLabFTWlater version.                 *
*                                                                               *
*    eLabFTW is distributed in the hope that it will be useful,                 *
*    but WITHOUT ANY WARRANTY; without even the implied                         *
*    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR                    *
*    PURPOSE.  See the GNU Affero General Public License for more details.      *
*                                                                               *
*    You should have received a copy of the GNU Affero General Public           *
*    License along with eLabFTW.  If not, see <http://www.gnu.org/licenses/>.   *
*                                                                               *
********************************************************************************/
require_once '../inc/common.php';
$user = new \Elabftw\Elabftw\User();
$crypto = new \Elabftw\Elabftw\CryptoWrapper();
$errflag = false;
/*
 * FIRST PART
 *
 * We send an email with a link + a key + the userid.
 *
 */
if (isset($_POST['email'])) {
    // Get infos about the requester (will be sent in the mail afterwards)
    // Get IP
    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
        $ip = $_SERVER['HTTP_CLIENT_IP'];
    } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
Exemplo n.º 4
0
*    it under the terms of the GNU Affero General Public License as             *
*    published by the Free Software Foundation, either version 3 of             *
*    the License, or (at your option) any later version.                        *
*                                                                               *
*    eLabFTW is distributed in the hope that it will be useful,                 *
*    but WITHOUT ANY WARRANTY; without even the implied                         *
*    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR                    *
*    PURPOSE.  See the GNU Affero General Public License for more details.      *
*                                                                               *
*    You should have received a copy of the GNU Affero General Public           *
*    License along with eLabFTW.  If not, see <http://www.gnu.org/licenses/>.   *
*                                                                               *
********************************************************************************/
require_once '../inc/common.php';
$formKey = new \Elabftw\Elabftw\FormKey();
$user = new \Elabftw\Elabftw\User();
//Array to store validation errors
$msg_arr = array();
//Validation error flag
$errflag = false;
// Check the form_key
if (!isset($_POST['formkey']) || !$formKey->validate()) {
    // form key is invalid
    $msg_arr[] = _("Your session expired. Please retry.");
    $errflag = true;
}
// Check username (sanitize and validate)
if (isset($_POST['username']) && !empty($_POST['username'])) {
    $username = filter_var($_POST['username'], FILTER_SANITIZE_STRING);
} else {
    $username = '';