real api and clearer separation between server and client
[syp.git] / admin.php
1 <?php
2 /* Copyright (c) 2009 Arnaud Renevier, Inc, published under the modified BSD
3    license. */
4
5 require_once ("./inc/settings.php");
6 require_once ("./inc/db/mysql.php");
7 require_once ("./inc/utils.php");
8
9 $error = false;
10 try {
11     $connection->connect (DBHOST, DBUSER, DBPWD, DBNAME, DBPREFIX);
12     $usrtblexists = $connection->users_table_exists ();
13     $itemstblexists = $connection->items_table_exists ();
14 } catch (Exception $e) {
15     $error = true;
16 }
17 if (!$usrtblexists || !$itemstblexists) {
18     $error = true;
19 }
20     if ($error) {
21 ?>
22 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
23        "http://www.w3.org/TR/html4/loose.dtd">  
24 <html>
25 <head>
26       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
27       <title>SYP admin</title>
28       <link rel="stylesheet" href="./media/admin.css" type="text/css">
29 </head>
30 <body>
31     <p class="error center">SYP n'est pas correctement installé. Veuillez
32     consulter le fichier README.txt et suivez les instructions
33     d'installation.</p>
34 </body>
35 </html>
36 <?php
37     exit ();
38     } // if ($error)
39 ?>
40 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
41        "http://www.w3.org/TR/html4/loose.dtd">  
42 <html>
43 <head>
44       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
45       <title>SYP admin</title>
46
47       <link rel="stylesheet" href="./media/admin.css" type="text/css">
48       <link rel="stylesheet" href="./openlayers/theme/default/style.css" type="text/css">
49
50       <script type="text/javascript">
51         <?php 
52             $bbox = $connection->mbr ();
53             printf ("var sypOrig = [%.18F, %.18F, %.18F, %.18F];\n",
54                     $bbox [0], $bbox [1], $bbox [2], $bbox [3]); 
55         ?>
56       </script>
57       <script src="./js/jquery-1.3.2.js" type="text/javascript"></script>
58       <script src="./openlayers/OpenLayers.js" type="text/javascript"></script>
59       <script src="./js/admin.js" type="text/javascript"></script>
60
61     <noscript>
62     <style type="text/css">
63         #map, #editor, #admin, #login_area {
64             display: none;
65         }
66     </style>
67     </noscript>
68
69 </head>
70
71 <body>
72
73     <noscript>
74     <p>SYP nécessite javascript pour fonctionner. Veuillez activer les scripts
75        dans votre navigateur.</p>
76     </noscript>
77
78
79     <div id="map"></div>
80
81     <div id="admin" class="center">
82         <input id="newfeature_button" type="button" value="ajouter un emplacement">
83         <p id="server_comm"></p>
84         <p id="instructions"></p>
85     </div>
86
87     <p id="logout"><a href="logout.php">Déconnexion</a></p>
88
89     <div id="editor" class="center">
90         <input id="editor_close" type="image" src="openlayers/theme/default/img/close.gif"
91              title="fermer sans enregistrer" alt="fermer">
92         <form id="feature_update" method="post" enctype="multipart/form-data">
93             <label for="title">titre&nbsp;:</label><br>
94             <input id="title" name="title"><br>
95             <label for="description">description&nbsp;:</label><br>
96             <textarea id="description" name="description" rows="4"></textarea><br>
97             <div><img id="img"></div>
98             <input id="image_delete" type="button" value="supprimer l'image">
99             <div>
100                 <label for="image_file">ajouter une image&nbsp;:</label>
101                 <input id="image_file" type="file" name="image_file">
102             </div>
103             <br>
104             <div class="center">
105             <input id="validate_editor" type="submit" value="Valider les changements">
106             </div>
107             <input type="hidden" name="request">
108             <input type="hidden" name="lon">
109             <input type="hidden" name="lat">
110             <input type="hidden" name="fid">
111             <input type="hidden" name="keep_img">
112         </form>
113         <form id="feature_delete" method="post">
114             <input id="delete" type="submit" value="Supprimer la fiche">
115             <input type="hidden" name="request" value="del">
116             <input type="hidden" name="fid">
117         </form>
118     </div>
119
120       <div id="login_area"
121         <?php 
122         if ($connection->checkpwdmd5 ("admin", 
123                                $_COOKIE [sprintf ("%sauth", DBPREFIX)])) {
124             echo ' class="hidden"';
125         }
126       ?>>
127      <div id="login_transparency"></div>
128      <div id="login_padding"></div>
129      <div id="login_content">
130         <form id="login_form" method="post">
131             <table>
132                 <tr>
133                     <td><label for="password">mot de passe</label></td>
134                     <td style="width: 100%"><input id="password" name="password" type="password"></td>
135                 </tr>
136             </table>
137             <p class="center">
138                 <input id="login_submit" type="submit" value="Connexion">
139                 <input type="hidden" name="request" value="auth">
140             </p>
141             <p id="pwd_throbber" class="throbber center">
142                 Connexion en cours
143                 <img src="media/pwd_throbber.gif" alt="throbber">
144             </p>
145             <p class="error center" id="login_error"></p>
146         </form>
147      </div>
148      </div>
149
150      <iframe id="api_frame" name="api_frame" src="" frameborder="0" width="0" height="0"></iframe>
151
152 </body>
153 </html>