Esempio n. 1
0
$app->get('/account', function () {
    try {
        $r = DatawrapperSession::toArray();
        ok($r);
    } catch (Exception $e) {
        error('exception', $e->getMessage());
    }
});
/* get current language */
$app->get('/account/lang', function () use($app) {
    ok(DatawrapperSession::getLanguage());
});
/* set a new language */
$app->put('/account/lang', function () use($app) {
    $data = json_decode($app->request()->getBody());
    DatawrapperSession::setLanguage($data->lang);
    ok();
});
/* login user */
$app->post('/auth/login', function () use($app) {
    $payload = json_decode($app->request()->getBody());
    //  v-- don't expire login anymore
    $user = UserQuery::create()->findOneByEmail($payload->email);
    if (!empty($user) && $user->getDeleted() == false) {
        if ($user->getPwd() === secure_password($payload->pwhash)) {
            DatawrapperSession::login($user, $payload->keeplogin == true);
            ok();
        } else {
            Action::logAction($user, 'wrong-password', json_encode(get_user_ips()));
            error('login-invalid', __('The password is incorrect.'));
        }
Esempio n. 2
0
<?php

define('ROOT_PATH', dirname(dirname(__FILE__)) . '/');
define('NO_SLIM', 1);
define('NO_SESSION', 1);
require ROOT_PATH . 'lib/bootstrap.php';
if (isset($dw_config['memcache'])) {
    $memcache->flush();
    print "flushed memcache!\n";
} else {
    print "memcache is not configured.\n";
}
DatawrapperSession::setLanguage("de_DE");
print DatawrapperSession::getLanguage() . "\n";
print __("This little tool reduces the time needed to create a correct chart and embed it into any website from hours to seconds. It makes charting easy, and helps you avoiding common pitfalls.");