File: blog_del.php

package info (click to toggle)
dotclear 2.6.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 8,420 kB
  • sloc: php: 54,270; sql: 1,290; sh: 213; xml: 173; makefile: 158
file content (80 lines) | stat: -rw-r--r-- 2,125 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
# -- BEGIN LICENSE BLOCK ---------------------------------------
#
# This file is part of Dotclear 2.
#
# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
# Licensed under the GPL version 2.0 license.
# See LICENSE file or
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK -----------------------------------------

require dirname(__FILE__).'/../inc/admin/prepend.php';

dcPage::checkSuper();

$blog_id = '';
$blog_name = '';

if (!empty($_POST['blog_id']))
{
	try {
		$rs = $core->getBlog($_POST['blog_id']);
	} catch (Exception $e) {
		$core->error->add($e->getMessage());
	}

	if ($rs->isEmpty()) {
		$core->error->add(__('No such blog ID'));
	} else {
		$blog_id = $rs->blog_id;
		$blog_name = $rs->blog_name;
	}
}

# Delete the blog
if (!$core->error->flag() && $blog_id && !empty($_POST['del']))
{
	if (!$core->auth->checkPassword(crypt::hmac(DC_MASTER_KEY,$_POST['pwd']))) {
		$core->error->add(__('Password verification failed'));
	} else {
		try {
			$core->delBlog($blog_id);
			dcPage::addSuccessNotice(sprintf(__('Blog "%s" successfully deleted'), html::escapeHTML($blog_name)));

			http::redirect('blogs.php');
		} catch (Exception $e) {
			$core->error->add($e->getMessage());
		}
	}
}

dcPage::open(__('Delete a blog'),'',
	dcPage::breadcrumb(
		array(
			__('System') => '',
			__('Blogs') => 'blogs.php',
			__('Delete a blog') => ''
		))
);

if (!$core->error->flag())
{
	echo
	'<div class="warning-msg"><p><strong>'.__('Warning').'</strong></p>'.
	'<p>'.sprintf(__('You are about to delete the blog %s. Every entry, comment and category will be deleted.'),
	'<strong>'.$blog_id.' ('.$blog_name.')</strong>').'</p></div>'.
	'<p>'.__('Please give your password to confirm the blog deletion.').'</p>';

	echo
	'<form action="blog_del.php" method="post">'.
	'<div>'.$core->formNonce().'</div>'.
	'<p><label for="pwd">'.__('Your password:').'</label> '.
	form::password('pwd',20,255).'</p>'.
	'<p><input type="submit" class="delete" name="del" value="'.__('Delete this blog').'" />'.
	form::hidden('blog_id',$blog_id).'</p>'.
	'</form>';
}

dcPage::close();