2023-10-22 01:46:22 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class Admin extends Page {
|
|
|
|
|
|
|
|
function loginas()
|
|
|
|
{
|
|
|
|
$user = $_REQUEST['email'];
|
|
|
|
|
|
|
|
$u = new User();
|
|
|
|
if($u->load($user))
|
|
|
|
{
|
|
|
|
$u->login();
|
|
|
|
$this->redirect('/');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->set('message', 'User '.escape($user).' not found');
|
|
|
|
$this->set('template', 'notfound.html');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function edituser()
|
|
|
|
{
|
|
|
|
$user = $_REQUEST['email'];
|
|
|
|
|
|
|
|
$u = new User();
|
|
|
|
if($u->load($user))
|
|
|
|
{
|
|
|
|
$data = $u->data;
|
|
|
|
$this->set('userdata', $data);
|
|
|
|
$this->set('userid', $user);
|
|
|
|
$this->set('template', 'edituser.html');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->set('message', 'User '.escape($user).' not found');
|
|
|
|
$this->set('template', 'notfound.html');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function edituserdata()
|
|
|
|
{
|
|
|
|
$user = $_REQUEST['email'];
|
|
|
|
|
|
|
|
$u = new User();
|
|
|
|
if(!$u->load($user))
|
|
|
|
{
|
|
|
|
$this->set('message', 'User '.escape($user).' not found');
|
|
|
|
$this->set('template', '/templates/notfound.html');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach($_REQUEST as $key => $value)
|
|
|
|
{
|
|
|
|
if($key == 'email') continue;
|
2023-10-22 23:05:24 +02:00
|
|
|
if($key=='dogs')
|
|
|
|
{
|
|
|
|
$value = json_decode(html_entity_decode($value),true);
|
|
|
|
}
|
2023-10-22 01:46:22 +02:00
|
|
|
$u->$key = $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
try{
|
|
|
|
$u->save();
|
|
|
|
}
|
|
|
|
catch(Exception $e)
|
|
|
|
{
|
2023-10-22 23:05:24 +02:00
|
|
|
$this->set('errorMessage', $e->getMessage());
|
2023-10-22 11:28:37 +02:00
|
|
|
$this->set('template', '/templates/partials/error.html');
|
2023-10-22 01:46:22 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
2023-10-22 23:05:24 +02:00
|
|
|
$this->set('successMessage', 'Speichern erfolgreich');
|
2023-10-22 11:28:37 +02:00
|
|
|
$this->set('template', '/templates/partials/success.html');
|
2023-10-22 01:46:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function maySeeThisPage(){return true;}
|
|
|
|
}
|