Ejemplo n.º 1
0
<?php

namespace Gallery;

use Gallery\Database\DB;
use Gallery\Utilities\UserState;
use Gallery\Utilities\Parameters;
use Gallery\Utilities\Redirect;
$r = new Redirect();
$state = new UserState();
if ($state->isState('authorized')) {
    $login = $state->getState('authorized');
    $db = new DB();
    $images = $db->getImagesByUser($login);
    $db->deleteUser($login);
    $param = new Parameters();
    $path = $param->imagesPath . $login;
    foreach ($images as $img) {
        unlink($path . DIRECTORY_SEPARATOR . $img . '.jpg');
        unlink($path . DIRECTORY_SEPARATOR . $img . $param->previewSuffix . '.jpg');
    }
    rmdir($path);
    $state->unsetState('authorized');
    $r->with(['msg' => "Аккаунт удален."]);
} else {
    Redirect::toRoot();
}