Mercurial > hg > fapweb
annotate print.php @ 122:7d9e8c82e744
Work on votekey printing.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 22 Oct 2013 14:40:42 +0300 |
parents | d9de08fb5b28 |
children | aeebfedb5709 |
rev | line source |
---|---|
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 <? |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 // |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 // Printing / hardcopy output helper module |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
4 // |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 $sessionType = "admin"; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 require "mconfig.inc.php"; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 require "msite.inc.php"; |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
8 require "mcommon.inc.php"; |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 require "msession.inc.php"; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
11 $pageCSS = "hardcopy.css"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
12 |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 // Check if we are allowed to execute |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
14 if (!stCheckHTTPS() || !stAdmSessionAuth(TRUE)) |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 { |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 stSetupCacheControl(); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 stSessionEnd(SESS_ADMIN); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 stSetStatus(404, "Not Found"); |
122 | 21 |
22 cmPrintPageHeader("Error"); | |
23 echo "<h1>Permission denied</h1>\n". | |
24 "<p>You need to be logged in as administrator to access this data.</p>\n". | |
25 "<p><a href=\"admin\">Click here for login form</a></p>\n"; | |
26 cmPrintPageFooter(); | |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
27 exit; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
29 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 stSetupCacheControl(); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 // Initiate SQL database connection |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 if (!stConnectSQLDB()) |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 die("Could not connect to SQL database."); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
35 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
36 // Fetch non-"hardcoded" settings from SQL database |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
37 stReloadSettings(); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
38 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 if (stChkRequestItem("type")) |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
40 $type = $_REQUEST["type"]; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
42 switch ($type) |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
43 { |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
44 case "email": |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
45 // |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
46 // Generic e-mail data dump |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
47 // |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
48 $sql = "SELECT * FROM attendees WHERE email NOT NULL AND email != '' ORDER BY regtime DESC"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
49 if (($res = stExecSQL($sql)) !== FALSE) |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 { |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
51 cmPrintPageHeader("E-mails"); |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 $out1 = array(); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 $out2 = array(); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 foreach ($res as $item) |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 { |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
57 $out1[] = $item["name"]." <".$item["email"].">"; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 $out2[] = $item["email"]; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
60 |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
61 echo |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
62 implode(", ", $out1)."<br /><hr /><br />\n". |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
63 implode("<br />", $out1)."<br /><hr /><br />\n". |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
64 implode(", ", $out2)."<br /><hr /><br />\n". |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
65 implode("<br />", $out2)."<br /><hr />\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
66 |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
67 cmPrintPageFooter(); |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
68 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
69 break; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
71 case "votekeys": |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 // |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
73 // Print out votekeys as a table |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
74 // |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
75 $sql = "SELECT * FROM votekeys ORDER BY id ASC"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
76 if (($res = stExecSQL($sql)) !== FALSE) |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
77 { |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
78 cmPrintPageHeader("Votekeys"); |
122 | 79 $keyLen = stGetSetting("userKeyLength"); |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
80 echo "<table class=\"votekeys\">\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
81 $index = 0; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
82 foreach ($res as $item) |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
83 { |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
84 if ($index == 0) |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
85 echo "<tr>\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
86 |
122 | 87 // This funny code is to ensure that the cells are of uniform width |
88 printf("<td><span class=\"keyid\">%03d</span> : ". | |
89 "<span class=\"keycode\">%s</span></td>\n", | |
90 $item["id"], | |
91 str_repeat(" ", $keyLen - strlen($item["key"])).$item["key"]); | |
95
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
92 |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
93 if ($index++ >= 5) |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
94 { |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
95 echo "</tr>\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
96 $index = 0; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
97 } |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
98 } |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
99 if ($index > 0) |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
100 echo "</tr>\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
101 |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
102 echo "</table>\n"; |
d9de08fb5b28
Work on hardcopy/votekey list printing.
Matti Hamalainen <ccr@tnsp.org>
parents:
91
diff
changeset
|
103 cmPrintPageFooter(); |
91
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
104 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
105 break; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
106 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
107 default: |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
108 stSetStatus(404, "Not Found"); |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
109 break; |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
110 } |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
111 |
b58a36f4821e
Initial addition of hardcopy / print helper module.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
112 ?> |