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