Dotclear

source: plugins/private/index.php @ 2117

Revision 2117, 4.4 KB checked in by Osku, 14 years ago (diff)

Plugin private : update to last version

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ----------------------------------
3#
4# This file is part of Private mode, a plugin for Dotclear 2.
5#
6# Copyright (c) 2008-2010 Osku and contributors
7#
8# Licensed under the GPL version 2.0 license.
9# A copy of this license is available in LICENSE file or at
10# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
11#
12# -- END LICENSE BLOCK ------------------------------------
13
14// Getting current parameters
15$private_flag = (boolean)$core->blog->settings->private_flag;
16$private_conauto = (boolean)$core->blog->settings->private_conauto;
17$blog_private_title = $core->blog->settings->blog_private_title;
18$blog_private_msg = $core->blog->settings->blog_private_msg;
19
20if (!empty($_POST['saveconfig']))
21{
22     try
23     {
24          $private_flag = (empty($_POST['private_flag']))?false:true;
25          $private_conauto = (empty($_POST['private_conauto']))?false:true;
26          $blog_private_title = $_POST['blog_private_title'];
27          $blog_private_msg = $_POST['blog_private_msg'];
28          $blog_private_pwd = md5($_POST['blog_private_pwd']);
29
30          if (empty($_POST['blog_private_title'])) {
31               throw new Exception(__('No page title.'));
32          }
33
34          if (empty($_POST['blog_private_msg'])) {
35               throw new Exception(__('No private message.'));
36          }
37
38          $core->blog->settings->setNamespace('private');
39          $core->blog->settings->put('private_flag',$private_flag,'boolean','Protect your blog with a password');
40          $core->blog->settings->put('private_conauto',$private_conauto,'boolean','Allow automatic connection');
41          $core->blog->settings->put('blog_private_title',$blog_private_title,'string','Private page title');
42          $core->blog->settings->put('blog_private_msg',$blog_private_msg,'string','Private message');
43
44          if (!empty($_POST['blog_private_pwd'])) {
45               if ($_POST['blog_private_pwd'] != $_POST['blog_private_pwd_c']) {
46                    throw new Exception(__("Passwords don't match"));
47               }
48               $core->blog->settings->put('blog_private_pwd',$blog_private_pwd,'string','Private blog password');
49          }
50
51          $core->blog->triggerBlog();
52          http::redirect($p_url.'&config=1');
53     }
54
55     catch (Exception $e)
56     {
57          $core->error->add($e->getMessage());
58     }
59}
60if ($core->blog->settings->blog_private_pwd === null)
61{
62     $err = __('No password set.');
63}
64?>
65<html>
66<head>
67     <title><?php echo __('Private mode'); ?></title>
68     <?php echo dcPage::jsLoad('index.php?pf=private/js/config.js'); ?>
69</head>
70<body>
71<?php 
72
73if (isset($_GET['config'])) {
74     echo '<p class="message">'.__('Configuration successfully updated.').'</p>';
75}
76
77if (!empty($err)) echo '<p class="error">'.$err.'</p>'; 
78
79echo '<h2>'.html::escapeHTML($core->blog->name).' &rsaquo; '.__('Private mode').'</h2>';
80
81echo '<div id="private_options">'.
82     '<form method="post" action="'.$p_url.'">'.
83          '<fieldset>'.
84               '<legend>'. __('Plugin activation').'</legend>'.
85                    '<p class="field">'.
86                         form::checkbox('private_flag', 1, $private_flag).
87                         '<label class=" classic" for="private_flag">'.__('Enable private mode').'</label>'.
88                    '</p>'.
89          '</fieldset>'.
90          '<fieldset id="misc_options">'.
91               '<legend>'.__('Presentation options').'</legend>'.
92                    '<p><label class="required" title="'.__('Required field').'">'.
93                         __('New password:').
94                         form::password('blog_private_pwd',30,255).
95                    '</label></p>'.
96                    '<p><label class="required" title="'.__('Required field').'">'.
97                         __('Confirm password:').
98                         form::password('blog_private_pwd_c',30,255).
99                    '</label></p>'.
100                    '<p>'.
101                         form::checkbox('private_conauto', 1, $private_conauto).
102                         '<label class=" classic" for="private_conauto">'. __('Propose automatic connection to visitors').'</label>'.
103                    '</p>'.
104                    '<p class="form-note">'.
105                    __('With this option, the password could be stored in a cookie.').
106                    __('But it still remains a choice for the visitor.').
107                    '</p>'.
108                    '<p>'.sprintf(__('Don\'t forget to add a <a href="%s">widget</a> allowing disconnection from the blog.'),'plugin.php?p=widgets').'</p>'.
109                    '<p class="col"><label class="required" title="'.__('Required field').'">'.
110                         __('Private page title:').
111                         form::field('blog_private_title',20,255,html::escapeHTML($blog_private_title),'maximal').
112                    '</label></p>'.
113                    '<p class="area"><label class="required" title="'.__('Required field').'">'.
114                         __('Private message:').
115                         form::textarea('blog_private_msg',30,4,html::escapeHTML($blog_private_msg)).
116                    '</label></p>'.
117          '</fieldset>'.
118
119          '<p>'.form::hidden(array('p'),'private').
120          $core->formNonce().
121          '<input type="submit" name="saveconfig" value="'.__('Save configuration').'" /></p>'.
122     '</form>'.
123'</div>';
124?>
125</body>
126</html>
Note: See TracBrowser for help on using the repository browser.

Sites map