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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 195 - (show annotations) (download)
Sat Dec 8 16:47:03 2007 UTC (16 years, 5 months ago) by torben
File size: 1320 byte(s)
Use persistant connections / connection pooling for faster db access

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

  ViewVC Help
Powered by ViewVC 1.1.20