admin as default login user
[syp.git] / inc / html / admin.php
1 <?php
2 /* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD
3    license. */
4
5 $error = false;
6
7 if (!@include_once ("./inc/settings.php")) {
8     $error = true;
9 }
10 require_once ("./inc/db/mysql.php");
11 require_once ("./inc/utils.php");
12
13 try {
14     $connection->connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX);
15     $usrtblexists = $connection->users_table_exists ();
16     $itemstblexists = $connection->items_table_exists ();
17 } catch (Exception $e) {
18     $error = true;
19 }
20 if (!$usrtblexists || !$itemstblexists) {
21     $error = true;
22 }
23     if ($error) {
24 ?>
25 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
26        "http://www.w3.org/TR/html4/loose.dtd">  
27 <html lang="<?php echo $lang?>">
28 <head>
29       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
30       <title><?php ptrans('SYP admin')?></title>
31       <link rel="stylesheet" href="./media/admin.css" type="text/css">
32 </head>
33 <body>
34     <p class="error center"><?php ptrans('SYP is not correctly installed. Please follow README.txt instructions
35        and go to <a href="install.en.php">wizard</a>.')?></p>
36 </body>
37 </html>
38 <?php
39     exit ();
40     } // if ($error)
41
42     $user = $_COOKIE [sprintf ("%suser", DBPREFIX)];
43     $pwd = $_COOKIE [sprintf ("%sauth", DBPREFIX)];
44     $logged = ($connection->checkpwdmd5 ($user, $pwd));
45 ?>
46 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
47        "http://www.w3.org/TR/html4/loose.dtd">  
48 <html lang="<?php echo $lang?>">
49 <head>
50       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
51       <title><?php ptrans('SYP admin');?></title>
52
53       <link rel="stylesheet" href="./media/admin.css" type="text/css">
54       <link rel="stylesheet" href="./openlayers/theme/default/style.css" type="text/css">
55
56       <script type="text/javascript">
57         var SypStrings = {
58             AddItem: "<?php ptrans('add a place')?>",
59             Cancel: "<?php ptrans('cancel')?>",
60             DragDropHowto: "<?php ptrans('You can move an item by drag & droping it.')?>",
61             SelectHowto: "<?php ptrans('To modify an item data, select matching marker.')?>",
62             AddHowto: "<?php ptrans('Click on the map to add a marker.')?>",
63             ServerError: "<?php ptrans('There was a server error.')?>",
64             UnreferencedError: "<?php ptrans('Item was not registered on the server.')?>",
65             NochangeError: "<?php ptrans('No change was made.')?>",
66             RequestError: "<?php ptrans('Server did not understood request. That\'s probably caused by a bug in SYP.')?>",
67             ToobigError: "<?php ptrans('Image was too big and was not accepted by server.')?>",
68             UnauthorizedError: "<?php ptrans('Password is not correct.')?>",
69             NotimageError: "<?php ptrans('File does not look like an image.')?>",
70             UnconsistentError: "<?php ptrans('Server reply was inconsistent.')?>",
71             DelSucces: "<?php ptrans('Successfully removed.')?>",
72             UpdateSucces: "<?php ptrans('Save took place correctly.')?>",
73             emptyPasswordError: "<?php ptrans('Password cannot be empty')?>",
74             userPasswordmatchError: "<?php ptrans('Passwords do not match.')?>",
75             changeSamePass: "<?php ptrans('New password is the same as old password.')?>",
76             changePassBadPass: "<?php ptrans('Bad password.')?>",
77             changePassSuccess: "<?php ptrans('Password successfully changed.')?>",
78             newUserNonameError: "<?php ptrans('User name has not been set.')?>",
79             newUserExistsError: "<?php ptrans('User already exists in database.')?>",
80             newUserSuccess: "<?php ptrans('User successfully added.')?>",
81             DisabledForDemo: "<?php ptrans('This feature is not enabled on demo site')?>"
82         };
83
84         var sypSettings =  {
85             loggedUser: <?php printf ($logged ? "\"$user\"": "null")?>
86         };
87
88       </script>
89       <script src="./js/jquery-1.3.2.js" type="text/javascript"></script>
90       <script src="./openlayers/OpenLayers.js" type="text/javascript"></script>
91       <script src="./js/admin.js" type="text/javascript"></script>
92
93     <noscript>
94     <style type="text/css">
95         #map, #editor, #admin, #login_area {
96             display: none;
97         }
98     </style>
99     </noscript>
100
101 </head>
102
103 <body>
104
105     <noscript>
106     <p><?php ptrans('SYP needs javascript. Please activate scripts in your browser.')?></p>
107     </noscript>
108
109     <div id="header">
110     <?php other_languages($lang) ?>
111     <div id="user_management">
112         <p id="logout" class="user_link"><a href="logout.php"><?php ptrans('Logout')?></a></p>
113         <p id="change_pass" class="user_link"><a href=""><?php ptrans('Change my password')?></a></p>
114         <p id="add_user" class="user_link"><a href=""><?php ptrans('Add a co-administrator')?></a></p>
115     </div>
116         <div id="user_area">
117             <input id="user_close" type="image" src="openlayers/theme/default/img/close.gif"
118                         title="<?php ptrans('close without saving')?>" alt="<?php ptrans('close')?>">
119             <form id="changepass" method="post">
120                 <label for="pass_current"><?php ptrans('current password:')?></label>
121                 <br>
122                 <input id="pass_current" name="pass_current" type="password">
123                 <br>
124                 <label for="pass_new"><?php ptrans('new password:')?></label>
125                 <br>
126                 <input id="pass_new" name="pass_new" type="password">
127                 <br>
128                 <label for="pass_new_confirm"><?php ptrans('confirm new password:')?></label>
129                 <br>
130                 <input id="pass_new_confirm" name="pass_new_confirm" type="password">
131                 <br>
132                 <input id="pass_submit" name="pass_submit" type="submit" value="<?php ptrans('Validate password')?>">
133                 <input type="hidden" name="request" value="changepass">
134             </form>
135             <form id="newuser" method="post">
136                 <label for="newuser_name"><?php ptrans('user name:')?></label>
137                 <br>
138                 <input id="newuser_name" name="newuser_name">
139                 <br>
140                 <label for="newuser_password"><?php ptrans('user password:')?></label>
141                 <br>
142                 <input id="newuser_password" name="newuser_password" type="password" value="">
143                 <br>
144                 <label for="newuser_password_confirm"><?php ptrans('confirm password:')?></label>
145                 <br>
146                 <input id="newuser_password_confirm" name="newuser_password_confirm" type="password">
147                 <br>
148                 <input id="newuser_submit" name="newuser_submit" type="submit" value="<?php ptrans('Validate user')?>">
149                 <input type="hidden" name="request" value="newuser">
150                 </form>
151                 <p id="user_comm" class="center"></p>
152                 <p id="user_throbber" class="throbber center">
153                     <?php ptrans('Connecting')?>
154                     <img src="media/newuser-throbber.gif" alt="<?php ptrans('throbber')?>">
155                 </p>
156         </div>
157     </div>
158
159
160     <div id="map"></div>
161
162     <div id="admin" class="center">
163         <input id="newfeature_button" type="button" value="<?php ptrans('add a place')?>">
164         <p id="server_comm"></p>
165         <p id="instructions"></p>
166     </div>
167
168     <div id="editor" class="center">
169         <input id="editor_close" type="image" src="openlayers/theme/default/img/close.gif"
170              title="<?php ptrans('close without saving')?>" alt="<?php ptrans('close')?>">
171         <form id="feature_update" method="post" enctype="multipart/form-data">
172             <label for="title"><?php ptrans('title:')?></label><br>
173             <input id="title" name="title"><br>
174             <label for="description"><?php ptrans('description:')?></label><br>
175             <textarea id="description" name="description" rows="4"></textarea><br>
176             <div><img id="img"></div>
177             <input id="image_delete" type="button" value="<?php ptrans('delete image')?>">
178             <div>
179                 <label for="image_file"><?php ptrans('add an image:')?></label>
180                 <input id="image_file" type="file" name="image_file">
181             </div>
182             <br>
183             <div class="center">
184             <input id="validate_editor" type="submit" value="<?php ptrans('Validate changes')?>">
185             </div>
186             <input type="hidden" name="request">
187             <input type="hidden" name="lon">
188             <input type="hidden" name="lat">
189             <input type="hidden" name="fid">
190             <input type="hidden" name="keep_img">
191         </form>
192         <form id="feature_delete" method="post">
193             <input id="delete" type="submit" value="<?php ptrans('Delete item')?>">
194             <input type="hidden" name="request" value="del">
195             <input type="hidden" name="fid">
196         </form>
197         <p id="editor_throbber" class="throbber center">
198             <?php ptrans('Connecting')?>
199             <img src="media/editor-throbber.gif" alt="<?php ptrans('throbber')?>">
200         </p>
201     </div>
202
203       <div id="login_area"
204         <?php 
205         if ($logged) {
206             echo ' class="hidden"';
207         }
208       ?>>
209      <div id="login_transparency"></div>
210      <div id="login_padding"></div>
211      <div id="login_content">
212         <form id="login_form" method="post">
213         <div id="cookie_warning" class="center warn"><?php ptrans('You need to have cookies enabled to administrate SYP')?></div>
214             <table>
215                 <tr>
216                     <td><label for="user"><?php ptrans('user')?></label></td>
217                     <td style="width: 100%"><input id="user" name="user" value="admin"></td>
218                 </tr>
219                 <tr>
220                     <td><label for="password"><?php ptrans('password')?></label></td>
221                     <td style="width: 100%"><input id="password" name="password" type="password"></td>
222                 </tr>
223             </table>
224             <p class="center">
225                 <input id="login_submit" type="submit" value="<?php ptrans('Login')?>">
226                 <input type="hidden" name="request" value="auth">
227             </p>
228             <p id="pwd_throbber" class="throbber center">
229                 <?php ptrans('Connecting')?>
230                 <img src="media/pwd-throbber.gif" alt="<?php ptrans('throbber')?>">
231             </p>
232             <p class="error center" id="login_error"></p>
233         </form>
234      </div>
235      </div>
236
237      <iframe id="api_frame" name="api_frame" src="" frameborder="0" width="0" height="0"></iframe>
238
239 </body>
240 </html>