コード例 #1
0
ファイル: delete.php プロジェクト: rair/yacs
// not found
if (!isset($item['id'])) {
    include '../error.php';
    // permission denied
} elseif (!$permitted) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // no deletion in demo mode
} elseif (isset($_REQUEST['confirm']) && $_REQUEST['confirm'] == 'yes' && file_exists($context['path_to_root'] . 'parameters/demo.flag')) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation in demonstration mode.'));
    // deletion is confirmed
} elseif (isset($_REQUEST['confirm']) && $_REQUEST['confirm'] == 'yes') {
    // close the session on self-deletion
    if (Surfer::get_id() == $item['id']) {
        Surfer::reset();
    }
    // attempt to delete
    if (Users::delete($item['id'])) {
        // log item deletion
        $label = sprintf(i18n::c('Deletion: %s'), strip_tags($item['nick_name']));
        $description = Users::get_permalink($item);
        Logger::remember('users/delete.php: ' . $label, $description);
        // this can appear anywhere
        Cache::clear();
        // back to the index page
        Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/');
    }
    // deletion has to be confirmed
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
    Logger::error(i18n::s('The action has not been confirmed.'));