]> dev.renevier.net Git - syp.git/blob - inc/html/admin.php
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/" . (defined ("DBTYPE")? DBTYPE: "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 <?php
57     if (file_exists ("./media/admin_custom.css")) {
58         printf("    <link rel=\"stylesheet\" href=\"./media/admin_custom.css\" type=\"text/css\">\n");
59     }
60 ?>
61
62       <script type="text/javascript">
63         var SypStrings = {
64             AddItem: "<?php ptrans('add a place')?>",
65             Cancel: "<?php ptrans('cancel')?>",
66             DragDropHowto: "<?php ptrans('You can move an item by drag & droping it.')?>",
67             SelectHowto: "<?php ptrans('To modify an item data, select matching marker.')?>",
68             AddHowto: "<?php ptrans('Click on the map to add a marker.')?>",
69             ServerError: "<?php ptrans('There was a server error.')?>",
70             UnreferencedError: "<?php ptrans('Item was not registered on the server.')?>",
71             NochangeError: "<?php ptrans('No change was made.')?>",
72             RequestError: "<?php ptrans('Server did not understood request. That\'s probably caused by a bug in SYP.')?>",
73             ToobigError: "<?php ptrans('Image was too big and was not accepted by server.')?>",
74             UnauthorizedError: "<?php ptrans('Password is not correct.')?>",
75             NotimageError: "<?php ptrans('File does not look like an image.')?>",
76             UnconsistentError: "<?php ptrans('Server reply was inconsistent.')?>",
77             DelSucces: "<?php ptrans('Successfully removed.')?>",
78             UpdateSucces: "<?php ptrans('Save took place correctly.')?>",
79             emptyPasswordError: "<?php ptrans('Password cannot be empty')?>",
80             userPasswordmatchError: "<?php ptrans('Passwords do not match.')?>",
81             changeSamePass: "<?php ptrans('New password is the same as old password.')?>",
82             changePassBadPass: "<?php ptrans('Bad password.')?>",
83             changePassSuccess: "<?php ptrans('Password successfully changed.')?>",
84             newUserNonameError: "<?php ptrans('User name has not been set.')?>",
85             newUserExistsError: "<?php ptrans('User already exists in database.')?>",
86             newUserSuccess: "<?php ptrans('User successfully added.')?>",
87             DisabledForDemo: "<?php ptrans('This feature is not enabled on demo site')?>"
88         };
89
90         var sypSettings =  {
91             loggedUser: <?php printf ($logged ? "\"$user\"": "null")?>
92         };
93
94       </script>
95       <script src="./js/jquery-1.3.2.js" type="text/javascript"></script>
96       <script src="./openlayers/OpenLayers.js" type="text/javascript"></script>
97       <script src="./js/admin.js" type="text/javascript"></script>
98
99     <noscript>
100     <style type="text/css">
101         #map, #editor, #admin, #login_area {
102             display: none;
103         }
104     </style>
105     </noscript>
106
107 </head>
108
109 <body>
110
111     <noscript>
112     <p><?php ptrans('SYP needs javascript. Please activate scripts in your browser.')?></p>
113     </noscript>
114
115     <div id="header">
116     <?php other_languages($lang) ?>
117     <div id="user_management">
118         <p id="logout" class="user_link"><a href="logout.php"><?php ptrans('Logout')?></a></p>
119         <p id="change_pass" class="user_link"><a href=""><?php ptrans('Change my password')?></a></p>
120         <p id="add_user" class="user_link"><a href=""><?php ptrans('Add a co-administrator')?></a></p>
121     </div>
122         <div id="user_area">
123             <input id="user_close" type="image" src="openlayers/theme/default/img/close.gif"
124                         title="<?php ptrans('close without saving')?>" alt="<?php ptrans('close')?>">
125             <form id="changepass" method="post">
126                 <label for="pass_current"><?php ptrans('current password:')?></label>
127                 <br>
128                 <input id="pass_current" name="pass_current" type="password">
129                 <br>
130                 <label for="pass_new"><?php ptrans('new password:')?></label>
131                 <br>
132                 <input id="pass_new" name="pass_new" type="password">
133                 <br>
134                 <label for="pass_new_confirm"><?php ptrans('confirm new password:')?></label>
135                 <br>
136                 <input id="pass_new_confirm" name="pass_new_confirm" type="password">
137                 <br>
138                 <input id="pass_submit" name="pass_submit" type="submit" value="<?php ptrans('Validate password')?>">
139                 <input type="hidden" name="request" value="changepass">
140             </form>
141             <form id="newuser" method="post">
142                 <label for="newuser_name"><?php ptrans('user name:')?></label>
143                 <br>
144                 <input id="newuser_name" name="newuser_name">
145                 <br>
146                 <label for="newuser_password"><?php ptrans('user password:')?></label>
147                 <br>
148                 <input id="newuser_password" name="newuser_password" type="password" value="">
149                 <br>
150                 <label for="newuser_password_confirm"><?php ptrans('confirm password:')?></label>
151                 <br>
152                 <input id="newuser_password_confirm" name="newuser_password_confirm" type="password">
153                 <br>
154                 <input id="newuser_submit" name="newuser_submit" type="submit" value="<?php ptrans('Validate user')?>">
155                 <input type="hidden" name="request" value="newuser">
156                 </form>
157                 <p id="user_comm" class="center"></p>
158                 <p id="user_throbber" class="throbber center">
159                     <?php ptrans('Connecting')?>
160                     <img src="media/newuser-throbber.gif" alt="<?php ptrans('throbber')?>">
161                 </p>
162         </div>
163     </div>
164
165
166     <div id="map"></div>
167
168     <div id="admin" class="center">
169         <input id="newfeature_button" type="button" value="<?php ptrans('add a place')?>">
170         <p id="server_comm"></p>
171         <p id="instructions"></p>
172     </div>
173
174     <div id="editor" class="center">
175         <input id="editor_close" type="image" src="openlayers/theme/default/img/close.gif"
176              title="<?php ptrans('close without saving')?>" alt="<?php ptrans('close')?>">
177         <form id="feature_update" method="post" enctype="multipart/form-data">
178             <label for="title"><?php ptrans('title:')?></label><br>
179             <input id="title" name="title"><br>
180             <label for="description"><?php ptrans('description:')?></label><br>
181             <textarea id="description" name="description" rows="4"></textarea><br>
182             <div><img id="img"></div>
183             <input id="image_delete" type="button" value="<?php ptrans('delete image')?>">
184             <div>
185                 <label for="image_file"><?php ptrans('add an image:')?></label>
186                 <input id="image_file" type="file" name="image_file">
187             </div>
188             <br>
189             <div class="center">
190             <input id="validate_editor" type="submit" value="<?php ptrans('Validate changes')?>">
191             </div>
192             <input type="hidden" name="request">
193             <input type="hidden" name="lon">
194             <input type="hidden" name="lat">
195             <input type="hidden" name="fid">
196             <input type="hidden" name="keep_img">
197         </form>
198         <form id="feature_delete" method="post">
199             <input id="delete" type="submit" value="<?php ptrans('Delete item')?>">
200             <input type="hidden" name="request" value="del">
201             <input type="hidden" name="fid">
202         </form>
203         <p id="editor_throbber" class="throbber center">
204             <?php ptrans('Connecting')?>
205             <img src="media/editor-throbber.gif" alt="<?php ptrans('throbber')?>">
206         </p>
207     </div>
208
209       <div id="login_area"
210         <?php 
211         if ($logged) {
212             echo ' class="hidden"';
213         }
214       ?>>
215      <div id="login_transparency"></div>
216      <div id="login_padding"></div>
217      <div id="login_content">
218         <form id="login_form" method="post">
219         <div id="cookie_warning" class="center warn"><?php ptrans('You need to have cookies enabled to administrate SYP')?></div>
220             <table>
221                 <tr>
222                     <td><label for="user"><?php ptrans('user')?></label></td>
223                     <td style="width: 100%"><input id="user" name="user" value="admin"></td>
224                 </tr>
225                 <tr>
226                     <td><label for="password"><?php ptrans('password')?></label></td>
227                     <td style="width: 100%"><input id="password" name="password" type="password"></td>
228                 </tr>
229             </table>
230             <p class="center">
231                 <input id="login_submit" type="submit" value="<?php ptrans('Login')?>">
232                 <input type="hidden" name="request" value="auth">
233             </p>
234             <p id="pwd_throbber" class="throbber center">
235                 <?php ptrans('Connecting')?>
236                 <img src="media/pwd-throbber.gif" alt="<?php ptrans('throbber')?>">
237             </p>
238             <p class="error center" id="login_error"></p>
239         </form>
240      </div>
241      </div>
242
243      <iframe id="api_frame" name="api_frame" src="" frameborder="0" width="0" height="0"></iframe>
244
245 </body>
246 </html>