root/trunk/gregarius/admin/users.php

Revision 1561, 4.2 kB (checked in by mbonetti, 2 years ago)

Yay for gettext localization! This will probably break things big time.
Note that until intl/*.php isn't adapted the the new method, the trunk
won't be localized!

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2###############################################################################
3# Gregarius - A PHP based RSS aggregator.
4# Copyright (C) 2003 - 2006 Marco Bonetti
5#
6###############################################################################
7# This program is free software and open source software; you can redistribute
8# it and/or modify it under the terms of the GNU General Public License as
9# published by the Free Software Foundation; either version 2 of the License,
10# or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful, but WITHOUT
13# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14# FITNESS FOR A PARTICULAR PURPOSE.      See the GNU General Public License for
15# more details.
16#
17# You should have received a copy of the GNU General Public License along
18# with this program; if not, write to the Free Software Foundation, Inc.,
19# 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  or visit
20# http://www.gnu.org/licenses/gpl.html
21#
22###############################################################################
23# E-mail:          mbonetti at gmail dot com
24# Web page:        http://gregarius.net/
25#
26###############################################################################
27
28
29function set_admin_pass($uname=null,$pass=null) {
30        $sql = "select count(*) from " . getTable('users')
31                ." where password != '' and ulevel >=99";
32        list($adminexists) = rss_fetch_row(rss_query($sql));
33        if ($adminexists) {
34                die('Oops. Admin already exists!');
35        }
36       
37        if ($uname && $pass) {
38                rss_query( "update " . getTable('users') . " set uname='$uname', "
39                 ."password='" . md5(md5($pass)) . "' where ulevel=99" );
40                rss_invalidate_cache(); 
41                rss_redirect('admin/');
42                exit();
43        }
44       
45        admin_header();
46                ?>
47        <script type="text/javascript">
48        <!--
49                function on_submit_password_match() {
50                        pass=document.getElementById('password').value;
51                        pass2=document.getElementById('password2').value;
52                        if(pass !== pass2){
53                                msg = '<?php echo __('Passwords do not match!') ?>';
54                                document.getElementById('admin_match_result').innerHTML = msg;
55                                document.getElementById('password').value = '';
56                                document.getElementById('password2').value = '';
57                                return false;
58                        }else{
59                                document.getElementById('password2').value = '';
60                                return loginHandler();
61                        }
62                }       
63        -->
64        </script>
65       
66        <?php
67  echo "\n<div id=\"channel_admin\" class=\"frame\">";
68        echo "<h2></h2>\n"
69                . __('<p>No Administrator has been specified yet!</p><p>Please provide an Administrator username and password now!</p>');
70       
71        echo "<form action=\"".$_SERVER['PHP_SELF'] . "\" onsubmit=\"return on_submit_password_match();\" method=\"post\">\n"
72        ."<fieldset style=\"width:400px;\">"
73        ."<p><label style=\"display:block\" for=\"username\">".__('Username').":</label>\n"
74        ."<input type=\"text\" id=\"username\" name=\"username\" /></p>\n"
75        ."<p><label style=\"display:block\" for=\"password\">".__('Password').":</label>\n"
76        ."<input type=\"password\" id=\"password\" name=\"password\" /></p>\n"
77        ."<p><label style=\"display:block\" for=\"password2\">".__('Password (again)').":</label>\n"
78        ."<input type=\"password\" id=\"password2\" name=\"password2\" /></p>\n"
79        ."<p><input type=\"submit\" value=\"".__('OK')."\" /></p>\n"
80        ."<div style=\"display:inline;\" id=\"admin_match_result\"></div>\n"
81        ."</fieldset>\n"
82        ."</form>\n";
83       
84        echo "</div>\n";
85        admin_footer(); 
86        exit();
87}
88
89function rss_login_form($uname=null,$pass=null) {
90       
91        admin_header();
92  echo "\n<div id=\"channel_admin\" class=\"frame\">";
93               
94        echo "<form id=\"admin_login\" onsubmit=\"return loginHandler();\" 
95                style=\"text-align:center\" action=\"".$_SERVER['PHP_SELF'] ."\" method=\"post\">\n"
96        ."<fieldset>"
97        ."<legend>" . __('Please log in') . "</legend>\n"
98        ."<p><label style=\"display:block\" for=\"username\">".__('Username').":</label>\n"
99        ."<input type=\"text\" id=\"username\" name=\"username\" /></p>\n"
100        ."<p><label style=\"display:block\" for=\"password\">".__('Password').":</label>\n"
101        ."<input type=\"password\" id=\"password\" name=\"password\" /></p>\n"
102        ."<p id=\"admin_login_submit\"><input type=\"submit\" value=\"".__('Login')."\" /></p>\n"
103        ."<span style=\"display:inline;\" id=\"admin_login_result\"></span>\n"
104        ."</fieldset>\n"
105        ."</form>\n";
106       
107        echo "</div>\n";
108        admin_footer(); 
109        exit();
110}
111
112?>
Note: See TracBrowser for help on using the browser.