/[H9]/trunk/tntnet/dynamic/adm_server_config.ecpp
ViewVC logotype

Annotation of /trunk/tntnet/dynamic/adm_server_config.ecpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 143 - (hide annotations) (download)
Tue Dec 4 13:25:32 2007 UTC (16 years, 6 months ago) by torben
File size: 1319 byte(s)
Added server configuration option

1 torben 143 <%pre>
2     #include <tntdb/connect.h>
3     #include <tntdb/connection.h>
4     #include <tntdb/result.h>
5     #include <tntdb/row.h>
6     </%pre>
7    
8     <%config>
9     dburl;
10     </%config>
11    
12     <%session scope="global">
13     std::string userName;
14     bool isAdmin;
15     </%session>
16    
17     <{
18     if (userName.size() == 0)
19     {
20     reply.setHeader("Location", "index");
21     return HTTP_MOVED_TEMPORARILY;
22     }
23     }>
24    
25    
26     <&header title="Server Configuration">
27     </&header>
28     <h2>Server configuration</h2>
29     <{
30     std::string phonenr;
31    
32    
33     tntdb::Connection conn = tntdb::connect(dburl);
34    
35    
36     if (qparam.param("submit").size() > 0)
37     {
38     conn.execute("DELETE FROM config WHERE name='phonenr'");
39    
40     tntdb::Statement st = conn.prepare("INSERT INTO config (name,value) VALUES ('phonenr',:v1)");
41     st.setString("v1", qparam.param("phonenr"));
42     st.execute();
43     }
44    
45    
46     tntdb::Result res = conn.select("SELECT name,value FROM config");
47     for (int i=0; i<res.size(); ++i)
48     {
49     std::string name = res[i].getString(0);
50     std::string value = res[i].getString(1);
51    
52     if (name == "phonenr")
53     phonenr = value;
54     }
55    
56    
57     }>
58     <form method="post" action="adm_server_config">
59     <table border=0>
60     <tr>
61     <td>Server phone nr:&nbsp;</td>
62     <td><input type="text" name="phonenr" value="<$ phonenr $>">
63     </tr>
64     <tr>
65     <td>&nbsp;
66     <td><input type="submit"><input type="reset">
67     </tr>
68     </table>
69    
70     <input type="hidden" name="submit" value="1">
71     </form>
72    
73     <&footer>
74     </&footer>

  ViewVC Help
Powered by ViewVC 1.1.20